MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

controlling multiple instances of excel!

  Asked By: Mona    Date: Sep 08    Category: MS Office    Views: 676

I'm currently working on a multiple application vba project using excel
Running multiple routines to access company intranet website to query
database, i've been able to input the various data i need. the
problem i'm running into is that the query returns and excel
spreadsheet. (2nd instance of exel (exelmain class), i want to be able
to save and close that spreadsheet via code but can't seem to gain
access to the xl object to do so.... using an api i've been able to
"close" the workbook.. but as it hasn't been saved a save as widow
opens. I haven't been able to close or save the file through code...
any ideas how to reference/access multiple instances of excel like this?



2 Answers Found

Answer #1    Answered By: Baylen Smith     Answered On: Sep 08

You have two options:

Option 1 - fix your query code so it generates a spreadsheet within the same
instance of Excel as the code is running in. This is the option I would go

Option 2 - treat the new instance of excel as a different program and use ole
or sendkeys to control it.

There may be others.

Answer #2    Answered By: Lughaidh Fischer     Answered On: Sep 08

Option 1 would be ideal.. but i have no access to change or fix the original
query... and the IT dept doesn't seem to know anything about it or have the
desire to help me with the situation.

Option 2 is what i'm trying to accomplish... and the problem i am having is that
i can tell it to close.. but as the spreadsheet has never been saved before i
get the save as dialog window.. and cant seem to figure out how to send
keys/control it .. that's my stumbling block... i haven't been able to get
control of the instance to use the saveas/ close vba that i'm used to using in
one instance of excel. any ideas on it?

Didn't find what you were looking for? Find more on controlling multiple instances of excel! Or get search suggestion and latest updates.