Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't open xls file generated from Access unless I go to Task Manager 2

Status
Not open for further replies.

bPruFin

Programmer
Sep 16, 2004
10
US
I have the following code (in Access 2000):

Dim xlApp As Excel.Application
Set xlApp = New Excel.Application

xlApp.Workbooks.Open (NewFileName)

Dim xlBook As Excel.Workbook
Set xlBook = xlApp.Workbooks(1)

{more code here}

xlBook.Save
xlBook.Close
Set xlBook = Nothing

xlApp.Quit
Set xlApp = Nothing

After this code runs and I have output data from Access to Excel, I am unable to open the .xls file from Windows Explorer. Each time I have to go to Task Manager-->Processes, highlight EXCEL.EXE and then click <End Process>.

What am I missing?

Thanks!

- Bruce
 
This is a common problem when automating Excel. There can be several reasons, the most common is usage of unqualified references to Excel objects, methods and properties.

From what I see here, I'd recommend trying CreateObject in stead of using the New keyword:

[tt]Set xlApp = createobject("Excel.Application")[/tt]

And set the workbook object to the book you open:

[tt]Set xlBook = xlApp.Workbooks.Open(NewFileName)[/tt]

But I guess the real challenge migth be in the code you haven't posted. See for instance Excel automation fails second time code runs. If you can't get it to work, perhaps post some more code?

Roy-Vidar
 
Thanks Roy,

I will try this out. Unfortunately I'm busy with another project so I won't get back to this one until later in the week or next week at the earliest.

One question I do have, though, is what is meant by the term "unqualified reference"?

Thanks again!

- Bruce
 
Something like ActiveCell.xxx
instead of xlApp.ActiveCell.xxx

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top