Close Excel from within Word

S

spoefi

Form within Word, I open an excel-workbook, paste data in it, save th
workbook as "c:\..." and then i want to close the workbooks en Qui
excel.

The problem is that excel keeps on turning in the background and tha
it is not possible to open my excel-workbook by doubleclicking on it
It gives an error.

--------
Private xlApp As Object
Private xlWB As Object
Private mySheet As Object

Set xlApp = CreateObject("Excel.Application")
Set xlWB = xlApp.Workbooks.Ope
"c:\projects\asus\Ycomm.bestellingimportACZ.xls")
Set mySheet = xlWB.Sheets(1)


(...I put data in this templatesheet, which i save then in the pat
'strSaveAs')


xlWB.SaveAs strSaveAs
xlWB.Close False

Set xlWB = Nothing
xlApp.Application.Quit ' close the Excel application
Set xlApp = Nothing
 
J

Jon Peltier

You have to close all references to Excel objects. See if inserting this
line helps:

Set mySheet = Nothing

- Jon
 

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