run macro from onoter Excel session

D

Dan

Hi,
I am tring to run a macro from another open workbook on another excel session.
I have tried using
Application.Run (PathToFile & "\" & NameOfFile & "!MacroName")
but the it open a new wotkbook (read only) and also get stuck.

Any idea,
Thanks
 
C

Colbert Zhou [MSFT]

Hello Dan,

We need to get the corresponding Application COM object of that Excel
session and then call Application.Run() method.

To get that Excel session's Application object, we can call the
Marshal.BindToMoniker to get that workbook and then get the application
from the Workbook.Application.

http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marsh
al.bindtomoniker.aspx
http://www.xldennis.com/dloads/Access running instances of Excel V
B.txt
(Process_Approach_BindToMoniker part)

If you have any future questions or concerns, please let us know!


Best regards,
Ji Zhou
Microsoft Community Online Support Team
 
C

Colbert Zhou [MSFT]

Ok. Thanks Tim for the comments.

Dan,

In Excel native VBA, we can get another Excel session's Workbook object by
calling GetObject(pathname). Please refer to another post with the same
title you post. Peter gives an example code there.

If you need any future help on this, just let us know.


Best regards,
Ji Zhou
Microsoft Online Community Support Team
 

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