Closing (invisible) excel after writing

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Sergio
Posts: 45
Joined: 29 Sep 2013, 16:36

Closing (invisible) excel after writing

12 Apr 2016, 14:29

I have to create the simplest module to generate excel files. It works well as is, but I don't know how to close the connection once I've written to the file.

It is invisible so I can't just alt-F4. Can someone tell me how to do it?

Code: Select all

ID := "1234567"
saveFileName = %A_Desktop%\ID-%ID%.xlsx
ToolTip, running
Xl := ComObjCreate("Excel.Application") ;handle
Xl.Visible := False
Xl.Workbooks.Add ;add a new workbook
Xl.Range("A1").Value := "ID_Field"
Xl.Range("A2").Value := "TRG-" . TRGID
Xl.ActiveWorkbook.SaveAs(saveFileName)
;Xl.Close <- ??
return
Sergio
Posts: 45
Joined: 29 Sep 2013, 16:36

Re: Closing (invisible) excel after writing

12 Apr 2016, 14:51

wolf_II wrote:Xl.Quit ?
I've been Googling answers for over a year & haven't needed a single question. Of all things, this one stumped me.

That was it. Thanks

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: jaka1, mikeyww, ReyAHK, Rohwedder and 303 guests