Excel automation

G

Guest

Hi al

I am automating excel 97 from Access 97. When I finish running all my code, I leave the instance of excel open but set all references to excel objects to nothing

When I then close excel, excel.exe is not showing in the Task Manager processes. However, if I close the workbook, the instance of excel is hidden and excel.exe still shows in the Task Manager processes

Has anyone come across this. I was thinking that maybe i had left some references to excel objects still valid but cannot find where I may have done this

Would be grateful for any help

Thank
Michelle
 
B

Bob Phillips

Michelle,

Are you quitting the Excel app?

xlApp.Quit

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Michelle said:
Hi all

I am automating excel 97 from Access 97. When I finish running all my
code, I leave the instance of excel open but set all references to excel
objects to nothing.
When I then close excel, excel.exe is not showing in the Task Manager
processes. However, if I close the workbook, the instance of excel is
hidden and excel.exe still shows in the Task Manager processes.
Has anyone come across this. I was thinking that maybe i had left some
references to excel objects still valid but cannot find where I may have
done this.
 
T

Tom Ogilvy

Leaving references is easy to do. You need to qualify all references from
the Excel application level or at least from a reference that leads back to
the Excel application level. Sometimes this can be subtle. For example if
you did a sort

oxlApp.Workbooks(1).Worksheets(1).Range("A1").CurrentRegion.Sort _
Key1:=Range("A1"), Order1:=xlAscending

This would create a non releasable reference, since the argument to Key1 is
an unqualified reference.

--
Regards,
Tom Ogilvy

Michelle said:
Hi all

I am automating excel 97 from Access 97. When I finish running all my
code, I leave the instance of excel open but set all references to excel
objects to nothing.
When I then close excel, excel.exe is not showing in the Task Manager
processes. However, if I close the workbook, the instance of excel is
hidden and excel.exe still shows in the Task Manager processes.
Has anyone come across this. I was thinking that maybe i had left some
references to excel objects still valid but cannot find where I may have
done this.
 
T

Tushar Mehta

I am not sure I understand the problem. First you mention that you
leave the instance of XL open. OK, so XL should show up in Task
Manager.

Then you mention that you close it and it doesn't show up in the task
manager. As it shouldn't.

Then you mention that if you close the workbook XL is still running.
Shouldn't it be? The workbook is closed, XL hasn't been asked to quit.

To me it would appear that in each of the scenarios the system is doing
what you want it to do.

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
G

Guest

Perhaps I didn't explain it properly!!! - very probably.

ok here's what happens.

when my code finishes running I leave excel open for the user to edit the spreadsheet and save etc.

at the end of my code running is
set wbRoster = nothing 'the workbook
set xlapp = nothing 'the instance of excel

while the workbook is still open, if the user closes excel, no excel.exe in processes in task manager - as expected i agree.

however, if the user closes the workbook only, the instance of excel disappears so it can't be physically closed, and therefore it still appears in the processes in the task manager.

my aim is to have excel closed whether the user closes the workbook OR the application.

Hope this clarifies my problem.

Thanks
Michelle
 
T

Tushar Mehta

I could only test with XL2002 (since it was the last one installed on
my machine).

What happens is that when the workbook is closed, XL also goes away.
It's almost as if there is some application level setting that reminds
it that it was started via automation.

However, unlike your experience where XL97 remains in memory, XL2002
does not show up in the Win XP Task Manager. So, I assume it went away
properly.

It looks like you will have to come up with a detour. Maybe, you can
have an application level event procedure in an XL add-in that checks
if Windows.Count = 0 and if so does a application.quit?

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
T

Tom Ogilvy

I believe you can do the older version with

Start=>Run=> path to specific verions of excel 2002/excel.exe /unregserver

Run

Then

path to older verion of excel/Excel.exe /Regserver

Run

then you can automate the older version, then reset the registry.

--
Regards,
Tom Ogilvy


Tushar Mehta said:
I could only test with XL2002 (since it was the last one installed on
my machine).

What happens is that when the workbook is closed, XL also goes away.
It's almost as if there is some application level setting that reminds
it that it was started via automation.

However, unlike your experience where XL97 remains in memory, XL2002
does not show up in the Win XP Task Manager. So, I assume it went away
properly.

It looks like you will have to come up with a detour. Maybe, you can
have an application level event procedure in an XL add-in that checks
if Windows.Count = 0 and if so does a application.quit?

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
disappears so it can't be physically closed, and therefore it still appears
in the processes in the task manager.
 
T

Tushar Mehta

Ah, ah. Thanks, Tom. That's almost like making it look like the older
version was loaded after the newer version -- at least as far as the
changes are made with /regserver.

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
G

Guest

Thanks to you all for your help

I did manage to find a solution which was actually quite simple

xlapp.usercontrol = tru

did the tric

Thank
Michelle
 
T

Tushar Mehta

Interesting -- and something to remember. Thanks for sharing the
resolution.

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 

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