opening Excel and then closing it

M

Maury Markowitz

I have a file that is passed to me in XLS format, but I would much prefer to
work with it in CSV. So I did this...

' open the downloaded file in Excel and copy it over to L in csv format
Workbooks.Open "O:\Downloads\D00100001554_0.xls"
Workbooks("D00100001554_0.xls").ConflictResolution = xlLocalSessionChanges
Workbooks("D00100001554_0.xls").SaveAs "L:\Activity.csv", xlCSV
Workbooks("Activity.csv").Close False

This works fine except it leaves Excel open in the background. The only
thing to do is fine it in Processes and force quit it. Is there some way to
do this through code?

Maury
 
D

Douglas J. Steele

Presumably you opened an instance of Excel using either

Set variable = New Excel.Application

or

Set variable = CreateObject("Excel.Application")

You need to issue

variable.Application.Quit (some people say variable.Quit is sufficient)

and then, for good measure

Set variable = Nothing
 
M

Maury Markowitz

Douglas J. Steele said:
Presumably you opened an instance of Excel using either
Set variable = New Excel.Application
or
Set variable = CreateObject("Excel.Application")

Actually, no. The code I posted is ALL of the code. Simply talking to
Workbook is all you need -- but as you point out, leaves you "handleless".

Maury
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top