run macro from onoter Excel session

  • Thread starter Thread starter Dan
  • Start date Start date
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
 
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
 
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
 
Back
Top