Bonjour à tous,
J'ai une DLL (Cartes.dll) dans laquelle j'ai 4 images au format BMP.
J'arrive à afficher ces images sur une Gui mais comment faire pour en imprimer une dans un fichier Excel.
L'Udf Excel veut à tout prix le chemin d'une image. Comment contourner le problème ?
QQ a t'il une idée ?
► Afficher le texte
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <WinAPI.au3>
#include <Constants.au3>
#include <ExcelCOM_UDF.au3>
$oXl=ObjCreate("excel.Application")
$oXL.ScreenUpdating = true
$oXL.Visible = false
$oXL.workbooks.add
$newsheet = $oXL.Worksheets.Add
$oXl.ActiveSheet.PageSetup.Orientation = $xlPortrait ; portrait
$oXl.ActiveSheet.PageSetup.LeftMargin = $oXl.InchesToPoints(0.2)
$oXl.ActiveSheet.PageSetup.RightMargin = $oXl.InchesToPoints(0.2)
$oXl.ActiveSheet.PageSetup.CenterHorizontally = True
$oXl.ActiveSheet.PageSetup.CenterVertically = False
$Load_Lib = _WinAPI_LoadLibrary(@ScriptDir & "\Cartes.dll")
;Dans la DLL, les images sont appelées Card1, Card2, Card3 et Card4
;~ $GD = GUICreate("GD" , 500,300, -1, -1)
;~ $C1 = GUICtrlCreatePic("", 6, 10, -1, -1 )
;~ $hC1 = _WinAPI_LoadImage($Load_Lib, "Card1", $IMAGE_BITMAP, 57,105, $LR_CREATEDIBSECTION + $LR_DEFAULTSIZE + $LR_SHARED + $LR_DEFAULTCOLOR )
;~ $hMsg = GUICtrlSendMsg($C1, 0x0172, $IMAGE_BITMAP, $hC1)
;~ GUISetState(@SW_SHOW)
;~ While 1
;~ Switch GUIGetMsg()
;~ Case $GUI_EVENT_CLOSE
;~ ExitLoop
;~ EndSwitch
;~ WEnd
$oXL.Cells(1,5).Value = "T E S T"
$AA= _ExcelPictureInsert($oXl, @ScriptDir & "\bunny.Bmp", 10,100,36,24, True,True)
$hBmp = _WinAPI_LoadImage($Load_Lib, "Card1", $IMAGE_BITMAP,57,105, $LR_LOADFROMFILE )
_ExcelPictureInsert($oXl, $hC1, 100,100,57,105, True,True)
; _ExcelPictureInsert($oExcel, $sFilePath, $iLeft, $iTop, $iWidth, $iHeight, $fLinkToFile = False, $fSaveWithDoc = False)
_ExcelBookSaveAs($oXl, @ScriptDir & "\TEST.xls","xls", 0, 0, "", "", 1, 2)
;_ExcelBookSaveAs($oExcel, $sFilePath, $sType = "xls", $fAlerts = 0, $fOverWrite = 0, $sPassword = "", $sWritePassword = "", $iAccessMode = 1, $iConflictResolution = 2)
$oXL.quit
Exit
PS : En pièce jointe ma DLL