A
AC
Hi
I have some code which manipulates an Excel workbook. I am new to
this and do not think I have done it correctly as I can still see an
Excel.exe process in the task manager after I shut the workbook down
and quit excel. This process disappears once I shut my Access dbase
down so its clearly my code.
My code is below. A (new) Excel window pops up as the code executes
and this window disappears again once it is finished - which is
exactly what I want. However clearly some "excel" is still floating
around as its in the task manager. However the main idea here is to
(1) open an excel workbook and make it visible so we can see it, (2)
do some stuff, (3) shut down the workbook AND the excel app we opened
once we are done.
Note that initially I coded it only using wbDataWorkbook and no
myExcelApp, but this left the Excel application window open (and
focused) even when I closed the workbook, which is why I moved to
using myExcelApp in the first place.
Im certain I have screwed up.
All help appreciated
Andy C
Dim myExcelApp As Excel.Application
Dim wbDataWorkbook As Excel.Workbook
'Open the data file in Excel, and make it visible
Set myExcelApp = Excel.Application
myExcelApp.Workbooks.Open filename:=strDataFile, UpdateLinks:=0
Set wbDataWorkbook = myExcelApp.ActiveWorkbook
myExcelApp.Application.Visible = True
'Turn off calculations, large datasets can be really slow if
recalc is on
myExcelApp.Calculation = xlCalculationManual
'DOES SOME STUFF, this seems to work fine
'Clean up
myExcelApp.Calculation = xlCalculationAutomatic
wbDataWorkbook.Close SaveChanges:=False
myExcelApp.Quit
I have some code which manipulates an Excel workbook. I am new to
this and do not think I have done it correctly as I can still see an
Excel.exe process in the task manager after I shut the workbook down
and quit excel. This process disappears once I shut my Access dbase
down so its clearly my code.
My code is below. A (new) Excel window pops up as the code executes
and this window disappears again once it is finished - which is
exactly what I want. However clearly some "excel" is still floating
around as its in the task manager. However the main idea here is to
(1) open an excel workbook and make it visible so we can see it, (2)
do some stuff, (3) shut down the workbook AND the excel app we opened
once we are done.
Note that initially I coded it only using wbDataWorkbook and no
myExcelApp, but this left the Excel application window open (and
focused) even when I closed the workbook, which is why I moved to
using myExcelApp in the first place.
Im certain I have screwed up.
All help appreciated
Andy C
Dim myExcelApp As Excel.Application
Dim wbDataWorkbook As Excel.Workbook
'Open the data file in Excel, and make it visible
Set myExcelApp = Excel.Application
myExcelApp.Workbooks.Open filename:=strDataFile, UpdateLinks:=0
Set wbDataWorkbook = myExcelApp.ActiveWorkbook
myExcelApp.Application.Visible = True
'Turn off calculations, large datasets can be really slow if
recalc is on
myExcelApp.Calculation = xlCalculationManual
'DOES SOME STUFF, this seems to work fine
'Clean up
myExcelApp.Calculation = xlCalculationAutomatic
wbDataWorkbook.Close SaveChanges:=False
myExcelApp.Quit