- Offizieller Beitrag
Ah okay, hier noch mal schnell was angepasst.
Spoiler anzeigen
#include <Array.au3>
#include <Excel.au3>
#include <File.au3>
Opt('MustDeclareVars', 1)
[/autoit] [autoit][/autoit] [autoit]Local $loadPath_excel_format = @ScriptDir
Local $outputPath_txt_format = @ScriptDir & "\Output"
Local $archivPath_txt_format = @ScriptDir & "\Archiv"
;~ Local $loadPath_excel_format = "C:\Users\dacohelpdesk\Desktop\test\Input"
;~ Local $outputPath_txt_format = "C:\Users\dacohelpdesk\Desktop\test\Output"
;~ Local $archivPath_txt_format = "C:\Users\dacohelpdesk\Desktop\test\Archiv"
Local $oExcel = 0
[/autoit] [autoit][/autoit] [autoit]Local $excelFile_A = _FileListToArray($loadPath_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($loadPath_excel_format & '\' & $excelFile_A[$i], 0)
If @error Then ConsoleWrite('_ExcelBookOpen : ' & @error & ' ' & $loadPath_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($loadPath_excel_format & '\' & $excelFile_A[$i], $archivPath_txt_format, 9) Then ConsoleWrite('+>' & $loadPath_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