I have an autoit script which runs fine but it does not seem to close of the actual excel process. When going to the task manager the excel.exe is still running. I am using Windows 7 and MS Excel 2003.
I also found an other post concerning the same topic but this did not bring a solution either
Here my script:
TraySetToolTip("3M Datei suchen...")
$search = FileFindFirstFile("\\9.165.152.39\Lu_Erfurt\TeamReports\3M\" & @YEAR & "\" & @MON & "\*.xls")
If $search <> -1 Then
$all=""
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
$all=$all & $file & @CRLF
WEnd
FileClose($search)
$gefunden=0
For $tag=@MDAY to 1 step -1
if $tag<10 then $tag="0" & $tag
$3mtag="3M" & $tag & @mon & stringright(@year,2) & ".xls"
if StringInStr($all,$3mtag)>0 then
$gefunden=1
ExitLoop
EndIf
Next
If $gefunden<>0 then
$oExcel = _ExcelBookOpen("\\9.165.152.39\Lu_Erfurt\TeamReports\3M\" & @YEAR & "\" & @MON & "\" & $3mtag,0)
TraySetToolTip("3M-Reporting-Daten kopieren...")
_ExcelSheetActivate($oExcel,"summary")
$zeile=0
$total=""
while $total<>"total"
$zeile=$zeile+1
$total = _ExcelReadCell($oExcel, $zeile, 2)
WEnd
_ExcelSheetActivate($oExcel,"summary_Ger")
$db_de_off=_ExcelReadCell($oExcel, $zeile, 4)
$db_de_han=_ExcelReadCell($oExcel, $zeile, 6)
_ExcelSheetActivate($oExcel,"summary_UK")
$db_uk_off=_ExcelReadCell($oExcel, $zeile, 4)
$db_uk_han=_ExcelReadCell($oExcel, $zeile, 6)
_ExcelSheetActivate($oExcel,"summary_BE")
$db_be_off=_ExcelReadCell($oExcel, $zeile, 4)
$db_be_han=_ExcelReadCell($oExcel, $zeile, 6)
_ExcelSheetActivate($oExcel,"summary_IT")
$db_it_off=_ExcelReadCell($oExcel, $zeile, 4)
$db_it_han=_ExcelReadCell($oExcel, $zeile, 6)
_ExcelSheetActivate($oExcel,"summary_FR")
$db_fr_off=_ExcelReadCell($oExcel, $zeile, 4)
$db_fr_han=_ExcelReadCell($oExcel, $zeile, 6)
_ExcelSheetActivate($oExcel,"summary_AT")
$db_at_off=_ExcelReadCell($oExcel, $zeile, 4)
$db_at_han=_ExcelReadCell($oExcel, $zeile, 6)
_ExcelSheetActivate($oExcel,"summary_SP")
$db_es_off=_ExcelReadCell($oExcel, $zeile, 4)
$db_es_han=_ExcelReadCell($oExcel, $zeile, 6)
_ExcelSheetActivate($oExcel,"summary_CH")
$db_ch_off=_ExcelReadCell($oExcel, $zeile, 4)
$db_ch_han=_ExcelReadCell($oExcel, $zeile, 6)
_ExcelSheetActivate($oExcel,"summary_PT")
$db_pt_off=_ExcelReadCell($oExcel, $zeile, 4)
$db_pt_han=_ExcelReadCell($oExcel, $zeile, 6)
_ExcelSheetActivate($oExcel,"summary_NL")
$db_nl_off=_ExcelReadCell($oExcel, $zeile, 4)
$db_nl_han=_ExcelReadCell($oExcel, $zeile, 6)
_ExcelSheetActivate($oExcel,"summary_Nordics")
$db_no_off=_ExcelReadCell($oExcel, $zeile, 4)
$db_no_han=_ExcelReadCell($oExcel, $zeile, 6)
_ExcelSheetActivate($oExcel,"summary_PL")
$db_pl_off=_ExcelReadCell($oExcel, $zeile, 4)
$db_pl_han=_ExcelReadCell($oExcel, $zeile, 6)
_ExcelBookClose($oExcel, 0)
$file_3m=FileOpen("db_3m.txt",2)
FileWriteLine($file_3m,$db_de_off & ";" & $db_de_han)
FileWriteLine($file_3m,$db_uk_off & ";" & $db_uk_han)
FileWriteLine($file_3m,$db_be_off & ";" & $db_be_han)
FileWriteLine($file_3m,$db_it_off & ";" & $db_it_han)
FileWriteLine($file_3m,$db_fr_off & ";" & $db_fr_han)
FileWriteLine($file_3m,$db_at_off & ";" & $db_at_han)
FileWriteLine($file_3m,$db_es_off & ";" & $db_es_han)
FileWriteLine($file_3m,$db_ch_off & ";" & $db_ch_han)
FileWriteLine($file_3m,$db_pt_off & ";" & $db_pt_han)
FileWriteLine($file_3m,$db_nl_off & ";" & $db_nl_han)
FileWriteLine($file_3m,$db_no_off & ";" & $db_no_han)
FileWriteLine($file_3m,$db_pl_off & ";" & $db_pl_han)
fileClose($file_3m)
TraySetToolTip("Datei aufs Share kopieren...")
FileCopy("db_3m.txt","db_3m.csv",1)
$3MDate = @YDAY
$3MToolTip = "3M report imported: " & $3mtag ;& @MDAY & "/" & @MON & "/" & @YEAR
EndIf
Else
FileClose($search)
EndIf