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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA Problem - Not Quitting Properly 1

Status
Not open for further replies.

PaultheS

Programmer
May 12, 2005
92
0
0
CA
Okay, I have code in an Access module that creates an Excel sheet, does some stuff and then quits. Long story short, it looks like this:

Code:
Set xl = CreateObject("Excel.Application")
...some stuff...
xl.Quit
Set xl = Nothing

When I run it as visible, the Excel program opens, I see the spreadsheet being fiddled with, then I see the program close. However, in the System Process, I still have an EXCEL.EXE. The program is quite long so I can't paste the whole thing, but can anyone give me some tips about what to look for and what could be causing this?

Some more info. This only started to happen after I added these two lines of code, which are giving me an entirely different problem:

Code:
xlMainSheet.range("C2").Select
ActiveWindow.FreezePanes = True

This code seems to work sometimes, and give an odd error other times ("The remote server machine does not exist or is unavailable")... When I comment it out, the program quits normally.

Am I doing something dumb? I couldn't find much documentation at all about FreezePanes around the Internet, so I just tried a few things until it worked... Like I said, it works sometimes, but seems to cause these other problems.

Any guidance would be appreciated.
 
Replace this:
ActiveWindow.FreezePanes = True
By this:
xl.ActiveWindow.FreezePanes = True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The fact that you even read my post that fast is impressive. And then you fixed my problem to boot.

Anyway, thanks again for the help. I'll see if I can have my boss put you on the payroll.
 
I was having the same issue in AutoCAD (opening Excel) and after finding this thread, I changed the Declarations as follows:
Dim exWbk as WorkBook, ...

to

Dim exWbk as Excel.WorkBook, ...

And now the Excel Application actually quits. What's the reason for this?
 
Hi egc,

With
Code:
Dim exWbk as WorkBook
it may be that references to exWbk are causing multiple instantiation of Excel (because the object isn't tied to the other Excel objects) - which are then not all properly closed. I'd have to see more of the code to be sure but this does seem to be a 'problem' with Office 2003 - they've tightened up some code somewhere.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Okay. Very possible as we recently switched to MSO 2003. BTW, I do the usual clean up and close all WorkBooks, Set to Nothing, etc. Not doing this can also cause issues.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top