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

Checking To See If Excel Is Already Open

Status
Not open for further replies.

HaydenMB

IS-IT--Management
May 30, 2003
24
GB
Hi,

I have written some code that takes a template spreadsheet, populates it with required data and then automatically emails it to the Supplier.

The problem I have is that if the user has another excel spreadsheet open it always uses this as the template and not the file.

What I would like to know is how do I check that an Excel Application is already running so I can inform the user and exit the sub.

I am using the following to open the template if this is any help to you.
[red]
Set wsXL = appXL.Workbooks.Open(strTemplate)
[/red]
You help will be greatly appreciated

Keep Right On…
HM-B
 
Hi

I think you need something like

Set oXl = GetObject(, "Excel.Application")
oXl.Visible = False
oXl.Workbooks.Open (strTemplatePath & strTemplateName)

and trap error so:
Select Case Err.Number
Case 429
Set oXl = CreateObject("Excel.Application")
Resume Next


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top