ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Activate Macro Button Located In Another File (https://www.excelbanter.com/excel-programming/375983-activate-macro-button-located-another-file.html)

Aria[_2_]

Activate Macro Button Located In Another File
 
Hello,
My macro is located in macro.xls. How do you create the flexibilty to
be able rename this file and still be able to call it within another
file?

When I assign a button towards another file called Template.xls, I have
(Both files are opened at this point):
With mybutton
..OnAction="'Macro.xls'!ClearTemplate"
End With

If Macro.xls changes name prior to assign the button, how do I alter the
OnAction line? I've tried fiddling with;
Set curwksmacro = ActiveSheet
but I just couldn't point the OnAction line to refer to curwksmacro's
ClearTemplate macro.

Please help.

Thanks,
Aria




*** Sent via Developersdex http://www.developersdex.com ***

Dave Peterson

Activate Macro Button Located In Another File
 
The code to assign the macro to the button is in the same file?

With mybutton
OnAction= "'" & thisworkbook.name & "'!ClearTemplate"
End With

Aria wrote:

Hello,
My macro is located in macro.xls. How do you create the flexibilty to
be able rename this file and still be able to call it within another
file?

When I assign a button towards another file called Template.xls, I have
(Both files are opened at this point):
With mybutton
OnAction="'Macro.xls'!ClearTemplate"
End With

If Macro.xls changes name prior to assign the button, how do I alter the
OnAction line? I've tried fiddling with;
Set curwksmacro = ActiveSheet
but I just couldn't point the OnAction line to refer to curwksmacro's
ClearTemplate macro.

Please help.

Thanks,
Aria

*** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson

Aria[_2_]

Activate Macro Button Located In Another File
 
Hi Dave,
It works. Thank-you so much. Yes, the code to assign the macro is also
within macro.xls.

Thank-you so much.
Aria :)

*** Sent via Developersdex http://www.developersdex.com ***


All times are GMT +1. The time now is 05:35 PM.

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