Add-In Calls Sub in Active Workbook

P

Paige

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.
 
C

Chip Pearson

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)
 
P

Paige

Thanks, Chip - works like a charm!

Chip Pearson said:
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)
 

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