?
Solved

Activate a running Excel File from Outlook in VBA

Posted on 2009-05-06
6
Medium Priority
?
526 Views
Last Modified: 2012-05-06
Hi,

I would like to know how I can activate and use macros which are in a excel file already running.

The idea is to generate a event when a mail arrived in my outlook. I filter the subject and call a procedure if it meats a certain criteria.

I know how to open new excel instance and open a file but here my excel file is running already and I have several excel application (each one a different process in the task manager) running. In each excel application I have several excel files open.

I want to use something similar to

Set Xlapp = GetObject(, "Excel.application")

But i want to test if the excel file is runiing in that application or in another one. If it's not in that one, i need to test the seconf application. If no excel application has the file open I will open it but i need to make sure it's not open already.

Then once the file is found, I want to run a macro in that file.

Thanks for your help !

0
Comment
Question by:potter09
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 2000 total points
ID: 24315346
Use GetObject with the workbook path and assign the result to a workbook variable. If the file is already open, you will grab a reference to it; if not, it will be opened.
Regards,
Rory
0
 

Author Comment

by:potter09
ID: 24315423
Would it looks like:

Sub OpenXlFile

  Dim Xlbook as workbook  '/ ojbect which one?
  Dim TargetCell as range

  set Xlbook  = getobject("Y:\GCF\LiveFile.xls","Excel.application")

  TargetCell = Xlbook.sheets(1).range("A1").value

End Sub
0
 

Author Comment

by:potter09
ID: 24315492
I tried with

  set Xlbook  = getobject("Y:\GCF\LiveFile.xls") but I have an Automation error :

"The message filter indicated that the application is busy"

I tried with a C:\Testfile.xls (blank excel file) and it worked so i'm not sure what's going on.

On the Live file, bloomberg is runniing to have a live feed of stock market information, that's it.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:potter09
ID: 24315856
Ok issue solved. It had to do with the server path. I put the complete path instead of the shortcut "Y" and it worked. Thanks rorya !
0
 

Author Comment

by:potter09
ID: 24315883
Jus a question:

there is a password on the file to open. If the file is running there is no problem, but is there a way to put the password if the file is close ?

Thanks
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 24316078
I don't think you can supply a password with GetObject, no.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question