Sign in to follow this  
Followers 0

_ExcelClosebook not closing excel process

3 posts in this topic

Posted

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

Share this post


Link to post
Share on other sites



Posted

$oExcel.Quit

$oExcel=0

Try those 2.

Share this post


Link to post
Share on other sites

Posted

I think it depends on the version of AutoIt you use. Please give the latest beta a try.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.