Excel.exe not closing after transferspreadsheet

  • Thread starter Thread starter agarwallp
  • Start date Start date
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
 
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
 
Back
Top