Hallo,
Ist es möglich ein Bild im *.jpg Format in eine Excel Tabelle zu kopieren über Autoit ?
Sollte dann so aussehen.
autoit.de/wcf/attachment/7174/
mfg
oh-ha
Hallo,
Ist es möglich ein Bild im *.jpg Format in eine Excel Tabelle zu kopieren über Autoit ?
Sollte dann so aussehen.
autoit.de/wcf/attachment/7174/
mfg
oh-ha
Hier mal aus dem Hut, so in etwa sollte es gehen:
[autoit]$oExcel = ...... ; Excel-Objekt erstellen (Neu/Öffnen)
$oExcel.ActiveSheet.Range("A1").Select
$oExcel.ActiveSheet.Pictures.Insert("C:\Pfad\Pfad\Datei.jpg").Select
Edit:
Achja, die Größe der Grafik läßt sich mit Selection.ShapeRange.... anpassen. Einfach mal nach googeln.
Hallo BugFix
Danke dir, werde das mal Testen und dann Berichten, man wie mich der Excel kram Nervt.
Möchte Autoit Lernen und kämpfe mit Excel. War zu meinen DOS Zeiten noch bei weiten einfacher.
mfg
oh-ha
Es gibt auch eine Excel_UDF da sind diese Sachen als Funktionen hinterlegt.
OK geht. Wieder mal ein Problem Dank deiner Hilfe gelöst.
Falls mal einer was ähnliches machen möchte habe es so gemacht.
[autoit]Func Testbild()
$sFilePath1 = @ScriptDir & "\Liste\Test.xls" ; Diese Datei sollte bereits existieren
$oExcel =_ExcelBookOpen ($sFilePath1, $fVisible = 0) ; $fVisible = 0 (die 0 für sichtbar 1 = unsichtbar)
$Pfad = @ScriptDir &"\1.jpg"
$oExcel.ActiveSheet.Range("A1").Select
$oExcel.ActiveSheet.Pictures.Insert("D:\Test\Kleines Tool\Skript\1.bmp").Select
EndFunc ;==>Testbild
mfg
oh-ha
@Xeno: Picture einbinden ist nur in die Word-UDF integriert.
jo nur den richtigen Durchblick habe ich da nicht oder noch nicht.
Wenn man weis wonach man suchen muss kann man da schon drin stöbern.
Du als Wissender kannst dir hoffentlich noch vorstellen wie das ist wenn man stundenlang an einem vermeintlichen Problem sitzt
und null weiterkommt. So ergeht es mir derzeitig. Poste eigentlich nur nach dem ich wieder mal feststecke.
mfg
oh-ha
@Xeno: Picture einbinden ist nur in die Word-UDF integriert.
Ach ja
Hier mal ein Auszug!
;===============================================================================
;
; 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
;===============================================================================
;
; Description: Change the position or rotation of a picture object created with _ExcelPictureInsert().
; Syntax: _ExcelPictureAdjust($oPicture, $iHorizontal, $iVertical, $iRotation = 0)
; Parameter(s): $oPicture - An Excel picture object opened by a preceding call to _ExcelPictureInsert()
; $iHorizontal - The number of points to move the picture left or right (positive numbers move the picture to the right)
; $iVertical - The number of points to move the picture up or down (positive numbers move the picture down)
; $iRotation - The number of degrees to rotate the picture clockwise (relative to current position)
; Requirement(s): None
; Return Value(s): On Success - Returns 1
; On Failure - Returns 0 and sets @error on errors:
; @error=1 - Specified object does not exist
; @error=2 - Parameter incorrect
; @extended=0 - $iHorizontal is not a number
; @extended=1 - $iVertical is not a number
; @extended=2 - $iRotation is not a number
; Author(s): SEO <locodarwin at yahoo dot com>
; Note(s): None
;
;===============================================================================
Func _ExcelPictureAdjust($oPicture, $iHorizontal, $iVertical, $iRotation = 0)
If Not IsObj($oPicture) Then Return SetError(1, 0, 0)
If Not IsNumber($iHorizontal) Then Return SetError(2, 0, 0)
If Not IsNumber($iVertical) Then Return SetError(2, 1, 0)
If Not IsNumber($iRotation) Then Return SetError(2, 2, 0)
$oPicture.Select
With $oPicture.Selection.ShapeRange
.IncrementTop($iVertical)
.IncrementLeft($iHorizontal)
.IncrementRotation($iRotation)
EndWith
Return 1
EndFunc ;==>_ExcelPictureAdjust
;===============================================================================
;
; Description: Scale a picture object created with _ExcelPictureInsert().
; Syntax: _ExcelPictureScale($oPicture, $nScaleWidth = 1, $nScaleHeight = 1, $iScaleOrigWidth = True, $iScaleOrigHeight = True, $iScaleFrom = 0)
; Parameter(s): $oPicture - An Excel picture object opened by a preceding call to _ExcelPictureInsert()
; $nScaleWidth - The width scale factor to assign to the picture (1.0 = original size)
; $nScaleHeight - The height scale factor to assign to the picture (1.0 = original size)
; $fScaleOrigWidth - Scale based on original width (True or False)
; $fScaleOrigHeight - Scale based on original height (True or False)
; $iScaleFrom - Specifies which part of the shape retains its position when the shape is scaled
; (0 = Scale from top left, 1 = Scale from middle, 2 = Scale from bottom right)
; Requirement(s): None
; Return Value(s): On Success - Returns 1
; On Failure - Returns 0 and sets @error on errors:
; @error=1 - Specified object does not exist
; @error=2 - Parameter incorrect
; @extended=0 - $nScaleWidth is not a number
; @extended=1 - $nScaleHeight is not a number
; @extended=2 - $fScaleOrigWidth is neither True nor False
; @extended=3 - $fScaleOrigHeight is neither True nor False
; @extended=4 - $iScaleFrom parameter incorrect (out of range)
; Author(s): SEO <locodarwin at yahoo dot com>
; Note(s): None
;
;===============================================================================
Func _ExcelPictureScale($oPicture, $nScaleWidth = 1, $nScaleHeight = 1, $fScaleOrigWidth = True, $fScaleOrigHeight = True, $iScaleFrom = 0)
If Not IsObj($oPicture) Then Return SetError(1, 0, 0)
If Not IsNumber($nScaleWidth) Then Return SetError(2, 0, 0)
If Not IsNumber($nScaleHeight) Then Return SetError(2, 1, 0)
If $fScaleOrigWidth <> True Or $fScaleOrigWidth <> False Then Return SetError(2, 2, 0)
If $fScaleOrigHeight <> True Or $fScaleOrigHeight <> False Then Return SetError(2, 3, 0)
If Not IsNumber($iScaleFrom) Then Return SetError(2, 4, 0)
If Not $iScaleFrom < 1 Or $iScaleFrom > 2 Then Return SetError(2, 4, 0)
$oPicture.ScaleWidth($nScaleWidth, $fScaleOrigWidth, $iScaleFrom)
$oPicture.ScaleHeight($nScaleHeight, $fScaleOrigHeight, $iScaleFrom)
Return 1
EndFunc ;==>_ExcelPictureScale
Mega