close app Excel

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

close app Excel

Post by sal21 »

Code: Select all

...
    Set EXCAPP = CreateObject("Excel.Application")
    Set EXDOC = EXCAPP.Workbooks.Open("C:\SERVIZIO\EXPORT\TEST_LISTINO_R.xlsx")
    Set WS = EXDOC.Worksheets("FOGLIO1") 
    EXCAPP.Visible = False
...
i dim EXCAPP , EXDOC and WS as Object

To the end of code, to be sure, i need to close all object or only to set nothing all variable?

User avatar
HansV
Administrator
Posts: 78237
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: close app Excel

Post by HansV »

To make sure that Excel is not running any more, use

Code: Select all

    EXDOC.Close SaveChanges:=True ' or False, depending on what you want
    EXCAPP.Quit
Best wishes,
Hans