Genau!
Siehe hier:
Local $inputPath_excel_format = "C:\Users\dacohelpdesk\Desktop\test\Input" <-- da deine Excel
Local $outputPath_txt_format = "C:\Users\dacohelpdesk\Desktop\test\Output" <-- da kommen die umgewandelten txt hin
Local $archivPath_excel_format = "C:\Users\dacohelpdesk\Desktop\test\Archiv" <-- da landen die Excel wenn es geklappt hat
Spoiler anzeigen
#include <Array.au3>
#include <Excel.au3>
#include <File.au3>
Opt('MustDeclareVars', 1)
[/autoit] [autoit][/autoit] [autoit];~ Local $inputPath_excel_format = @ScriptDir
;~ Local $outputPath_txt_format = @ScriptDir & "\Output"
;~ Local $archivPath_excel_format = @ScriptDir & "\Archiv"
Local $inputPath_excel_format = "C:\Users\dacohelpdesk\Desktop\test\Input"
Local $outputPath_txt_format = "C:\Users\dacohelpdesk\Desktop\test\Output"
Local $archivPath_excel_format = "C:\Users\dacohelpdesk\Desktop\test\Archiv"
Local $oExcel = 0
[/autoit] [autoit][/autoit] [autoit]Local $excelFile_A = _FileListToArray($inputPath_excel_format, '*.xls', 1)
If @error Then ConsoleWrite('_FileListToArray : ' & @error & @LF)
ConsoleWrite('Dateien: ' & @CRLF & _ArrayToString($excelFile_A) & @LF)
[/autoit] [autoit][/autoit] [autoit]For $i = 1 To UBound($excelFile_A) - 1
$oExcel = _ExcelBookOpen($inputPath_excel_format & '\' & $excelFile_A[$i], 0)
If @error Then ConsoleWrite('_ExcelBookOpen : ' & @error & ' ' & $inputPath_excel_format & '\' & $excelFile_A[$i] & @LF)
_ExcelBookSaveAs($oExcel, $outputPath_txt_format & '\' & StringLeft($excelFile_A[$i], StringInStr($excelFile_A[$i], '.', Default, -1) - 1), "txt")
If @error Then ConsoleWrite('_ExcelBookSaveAs : ' & @error & @LF)
_ExcelBookClose($oExcel, 1, 0)
If @error Then ConsoleWrite('_ExcelBookClose : ' & @error & @LF)
If FileExists($outputPath_txt_format & '\' & StringLeft($excelFile_A[$i], StringInStr($excelFile_A[$i], '.', Default, -1) - 1) & '.txt') = 1 Then
If FileMove($inputPath_excel_format & '\' & $excelFile_A[$i], $archivPath_excel_format, 9) Then ConsoleWrite('+>' & $inputPath_excel_format & '\' & $excelFile_A[$i] & ' erfolgreich archiviert' & @LF)
Else
ConsoleWrite('File not found : ' & $outputPath_txt_format & '\' & StringLeft($excelFile_A[$i], StringInStr($excelFile_A[$i], '.', Default, -1) - 1) & '.txt' & @LF)
EndIf
Next