Excel.exe not closing after transferspreadsheet

A

agarwallp

Hi I have the following code:

Dim xlapp As Excel.Application
Dim xlwkb As Excel.Workbook
Dim xlWs As Excel.Worksheet
Dim xlRng As Variant
Dim ret, a As Long

Set xlapp = CreateObject("Excel.application")
xlapp.Visible = True
Set xlwkb = xlapp.Workbooks.Open("H:\CRT\SCA\SG IM OFSGL930 - OFS
Account Listing - Dec.xls")
Set xlWs = xlwkb.Sheets(1)



DoCmd.TransferSpreadsheet acImport, 8, "tmp", "H:\CRT\SCA\SG IM
OFSGL930 - OFS Account Listing - Dec.xls", True, "A5:b310"

Set xlWs = Nothing
xlwkb.Close
Set xlwkb = Nothing
xlapp.Application.Quit
Set xlapp = Nothing

-------------------------------------
The import happens correctly but the excel.exe process is still
visible in taskmanager. If I have the DoCmd.TransferSpreadsheet after
closing the excel file,then excel.exe closes, but the problem is, I
get the error "the table contains cells that are outside the range of
cells defined in the spreadsheet"

Please help
 
P

Paolo

Hi agarwallp,

why do you open the excel application?
The only thing your code is doing is to import a spreadsheet and to do that
use just the DoCmd.TransferSpreadsheet statement.

HTH Paolo
 

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