ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add-In Calls Sub in Active Workbook (https://www.excelbanter.com/excel-programming/421340-add-calls-sub-active-workbook.html)

Paige

Add-In Calls Sub in Active Workbook
 
Can a sub in an add-in call a sub in another workbook? I need the add-in sub
to call a sub in the active workbook; the name of the active workbook
changes. Cannot figure out how to do this - keep getting error messages with
the application.run method. Any help would be appreciated.....thanks.

Chip Pearson

Add-In Calls Sub in Active Workbook
 
You can use Application.Run to do this. Something like

Sub RunIt()
Dim WBName As String
WBName = ActiveWorkbook.Name
Application.Run "'" & WBName & "'!ProcedureName"
End Sub

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Mon, 15 Dec 2008 08:59:01 -0800, Paige
wrote:

Can a sub in an add-in call a sub in another workbook? I need the add-in sub
to call a sub in the active workbook; the name of the active workbook
changes. Cannot figure out how to do this - keep getting error messages with
the application.run method. Any help would be appreciated.....thanks.


Paige

Add-In Calls Sub in Active Workbook
 
Thanks, Chip - works like a charm!

"Chip Pearson" wrote:

You can use Application.Run to do this. Something like

Sub RunIt()
Dim WBName As String
WBName = ActiveWorkbook.Name
Application.Run "'" & WBName & "'!ProcedureName"
End Sub

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Mon, 15 Dec 2008 08:59:01 -0800, Paige
wrote:

Can a sub in an add-in call a sub in another workbook? I need the add-in sub
to call a sub in the active workbook; the name of the active workbook
changes. Cannot figure out how to do this - keep getting error messages with
the application.run method. Any help would be appreciated.....thanks.




All times are GMT +1. The time now is 05:16 AM.

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