Problems with Excel objects transferring between methods in class module.

J

jqq

I have some working code that I'm trying to move to class modules (my
first try at classes). The code opens an Excel workbook, activates a
worksheet, collects some information from the worksheet, loops through
cells and uses the values in the calling program, then closes the
workbook. Windows XP, Excel 2003 (reference library Excel 11), WRQ
Reflections 11. I'm running terminal emulation scripts in Reflections
that need to call values from Excel. All of this code works as
subs/functions in a regular module.

I've set up a class module for the Excel code, created properties, and
created separate methods for Open/Activate, GetInfo, and Close. I need
to call the Open/Activate and then GetInfo methods, run the scripts
(pulling values from Excel), and then Close the workbook. Everything
runs fine the first time through, but on subsequent runs, I lose the
App/Wkbk/Wksht objects on the step after the first method call and get
"object required" errors thereafter. This problem remains until I
completely close and reopen Reflections.

The same problem happens when running the code from Access, so it's not
just a Reflections problem.

Can anyone give me a clue as to where my problem might lie? I'm not
sure which pieces of code you might need to see, please let me know &
I'll c&p it in.

Thanks very much for any suggestions!
 
B

BFree

Welcome to the biggest pain in hiney when automating excel; it's object
instances like to hang around even when properly destroyed and the app object
is closed. There are some KB articles you can research (search quitting
excel, etc) that can help, but generally I've found that some of the time,
some options work, but none of the time does one path work. You can also go
to the Excel vba discussion group and search there where you'll find,
unfortunately, more headaches. (Hate posting this kind of reply, but better
to know the ugly truth....) Best of luck, and if you find a bullet-proof
solution, please, by all means, share it.
 

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