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

VB Code when Excel Already Open

Status
Not open for further replies.

cariengon

Technical User
Mar 18, 2002
283
US
I've been searching for an answer, but nothing I have found works for me...

The problem I'm having is that I have an Excel Workbook Template that I use to populate data into from Access. If Excel is not running (or there are no other workbooks open) it opens fine and works correctly.

However, if Excel is running, I can't figure out how to make my workbook open. The procedure seems to run, but I cannot see the workbook that I need - as it shows the workbook that was already open (which isn't related to the Template I am using)

Here's the piece of the code I am running:

Code:
Dim xlsWKB As Object 'Variable for Workbook Name

Set xlsWKB = GetObject("C:\Contract Profile Form v2.01_TEST.xls")
xlsWKB.Application.Visible = True
xlsWKB.Parent.Windows(1).Visible = True

Everything I have found so far tells me how to check if an instance of excel is running. That's fine - but if the instance is running, how do I open my workbook into the running instance? This seems to only work if Excel is not running.

Thanks,
Carie
 
Have you tried this ?
xlsWKB.Activate

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
This made the workbook active ONLY if there wasn't an existing workbook open. If there is an existing workbook open, the workbook template that is being populated never activates.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top