Hallo zusammen
vorweg gesagt, ich bin nicht gerade sehr Affin in Autoit und tue mich mit einigen Sachen recht schwer im verstehen bzw den zusammen hängen.
Ich habe versucht weitestgehend alles mit Google und der Hilfe hin zu bekommen, nur leider hänge ich grade etwas fest.
Mein Programm soll folgendes tun:
In einer Excel Tabelle stehen Zahlen von Artikel Nummern. Zu jeder Artikel Nummer gibt es ein Bild was den auch den Namen der Artikel Nummer hat. Nun soll mein Programm eine Excel Tabelle auslesen, und mir die Bilder in ein vorher ausgewählten Ordner Kopieren.
Bis jetzt sieht mein Script so aus:
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <Excel.au3>
$Bilder = "K:\Bild\"
Example()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Excel datei auswählen
Func Example()
; Create a constant variable in Local scope of the message to display in FileOpenDialog.
Local Const $sMessage = "Select a single file of any type."
; Display an open dialog to select a file.
Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "Excel (*.xlsx) (*.xls)", $FD_FILEMUSTEXIST)
If @error Then
; Display the error message.
MsgBox($MB_SYSTEMMODAL, "", "Keine Datei ausgewählt es wird Abgebrochen.")
Exit
; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
FileChangeDir(@ScriptDir)
Else
; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
FileChangeDir(@ScriptDir)
; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
$sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF)
; Display the selected file.
MsgBox($MB_SYSTEMMODAL, "", "Folgende Datei wurde Geladen:" & @CRLF & $sFileOpenDialog)
EndIf
;==>Example
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Ordner zum Kopieren
; Create a constant variable in Local scope of the message to display in FileSelectFolder.
Local Const $sMessage2 = "Select a folder"
; Display an open dialog to select a file.
Local $sFileSelectFolder = FileSelectFolder($sMessage2, "")
If @error Then
; Display the error message.
MsgBox($MB_SYSTEMMODAL, "", "Es wurde kein Ordner gewählt.")
Exit
Else
; Display the selected folder.
MsgBox($MB_SYSTEMMODAL, "", "Folgendes Verzeichnis wurde gewählt:" & @CRLF & $sFileSelectFolder)
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Excel Datei Auslesen
; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, $sFileOpenDialog)
If @error Then
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error opening workbook '" & @ScriptDir & $sFileOpenDialog & @CRLF & "@error = " & @error & ", @extended = " & @extended)
_Excel_Close($oExcel)
Exit
EndIf
; Read the formulas of a cell range (all used cells in column A)
Local $aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:A"), 2)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 3", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 3", "Data successfully read." & @CRLF & "Please click 'OK' to display all formulas in column A.")
_ArrayDisplay($aResult, "Excel UDF: _Excel_RangeRead Example 3 - Formulas in column A")
EndFunc
Alles anzeigen
Ich gebe auch zu das ich viel einfach nur kopiert habe aus der Hilfe heraus, aber zumindest habe ich es auch (so denke ich zumindest) verstanden.
Nur Stehe ich total auf dem Schlauch was das Kopieren angeht. Zur zeit Listet Autoit mit alles auf was in Spalte A drin ist in einem Eigenen msgbox. Nur müsste ich das ja als Variable speichern um es zu kopieren. Und das verstehe ich nicht wie ich jede einzelne spalte als Variable zum Kopieren speichern kann.
Hoffe ihr könnt mir den weg erleuchten