Bild in Excel einfügen

  • Hallo zusammen,

    hat jemand von euch vieleicht schon eine Funktion um ein Bild aus einem Ordner in eine Zelle einzufügen? Wenn ja wäre toll, da ich momentan nich weiss, wo ich dabei anfangen soll. Danke vorab für eure Antworten.

    Gruß Alex

    Einmal editiert, zuletzt von pastl (2. Dezember 2011 um 00:17)

    • Offizieller Beitrag
    Spoiler anzeigen
    [autoit]

    ;===============================================================================
    ;
    ; Description: Insert a picture from a separate file into the active sheet.
    ; Syntax: _ExcelPictureInsert($oExcel, $sFilePath, $iLeft, $iTop, $iWidth, $iHeight, $fLinkToFile = False, $fSaveWithDoc = False)
    ; Parameter(s): $oExcel - An Excel object opened by a preceding call to _ExcelBookOpen() or _ExcelBookNew()
    ; $sFilePath - The full path of the picture to be inserted
    ; $fLinkToFile - "True" to link the picture to the file from which it was created.
    ; "False" to make the picture an independent copy of the file. The default value is False.
    ; $fSaveWithDoc - "True" to save the linked picture with the document. The default value is False.
    ; $iLeft - The position (in points) of the upper-left corner of the picture relative to the upper-left corner of the worksheet
    ; $iTop - The position (in points) of the upper-left corner of the picture relative to the top of the worksheet
    ; $iWidth - The width of the picture, in points
    ; $iHeight - The height of the picture, in points
    ; Requirement(s): None
    ; Return Value(s): On Success - Returns an object representing the inserted picture
    ; On Failure - Returns 0 and sets @error on errors:
    ; @error=1 - Specified object does not exist
    ; Author(s): SEO <locodarwin at yahoo dot com>
    ; Note(s): None
    ;
    ;===============================================================================
    Func _ExcelPictureInsert($oExcel, $sFilePath, $iLeft, $iTop, $iWidth, $iHeight, $fLinkToFile = False, $fSaveWithDoc = False)
    If NOT IsObj($oExcel) Then Return SetError(1, 0, 0)
    If NOT FileExists($sFilePath) Then Return SetError(2, 0, 0)
    If $iLeft < 1 Then $iLeft = 1
    If $iTop < 1 Then $iTop = 1
    If $iWidth < 1 Then $iWidth = 1
    If $iHeight < 1 Then $iHeight = 1
    $oExcel.ActiveSheet.Shapes.AddPicture($sFilePath, $fLinkToFile, $fSaveWithDoc, $iLeft, $iTop, $iWidth, $iHeight).Select
    Return $oExcel.Selection.ShapeRange
    EndFunc ;==>_ExcelPictureInsert

    [/autoit]