ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   run macro from onoter Excel session (https://www.excelbanter.com/excel-programming/435121-run-macro-onoter-excel-session.html)

dan

run macro from onoter Excel session
 
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



Colbert Zhou [MSFT]

run macro from onoter Excel session
 
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/libr...services.marsh
al.bindtomoniker.aspx
http://www.xldennis.com/dloads/Acces...of%20Excel%20V
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


Tim Williams[_2_]

run macro from onoter Excel session
 
I think the OP is working in Excel, not .NET

Tim

"Colbert Zhou [MSFT]" wrote in message
...
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/libr...services.marsh
al.bindtomoniker.aspx
http://www.xldennis.com/dloads/Acces...of%20Excel%20V
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




Colbert Zhou [MSFT]

run macro from onoter Excel session
 
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



All times are GMT +1. The time now is 12:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com