![]() |
Button, but now code
Hi,
I'm supplying my colleagues with an addin but also with a spreadsheet that has a button on it. I would prefer it if the button could call the code from the addin rather than a callback within the spreadsheet. This would save them the "Would you like to enable macros?". Very many thanks in advance, Aaron |
Button, but now code
Try to assign the macro below to the button.
You can easily change the values of the variables to make it work in your case. '--------------------------------------------------------- Private Sub CommandButton1_Click() Dim response Dim file_name As String Dim macro_name As String file_name = "file_name_of_addin.xla" macro_name = "name_of_macro_to_execute" response = MsgBox("Would you like to enable macros", vbYesNo + vbQuestion) If response = vbYes Then Application.Run Macro:="'" & file_name & "'!" & macro_name End If End Sub '--------------------------------------------------------- Regards, Edwin Tam http://www.vonixx.com ----- Aaron Fude wrote: ----- Hi, I'm supplying my colleagues with an addin but also with a spreadsheet that has a button on it. I would prefer it if the button could call the code from the addin rather than a callback within the spreadsheet. This would save them the "Would you like to enable macros?". Very many thanks in advance, Aaron |
Button, but now code
Why post twice? I replied to the other one.
-- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Aaron Fude" wrote in message ... Hi, I'm supplying my colleagues with an addin but also with a spreadsheet that has a button on it. I would prefer it if the button could call the code from the addin rather than a callback within the spreadsheet. This would save them the "Would you like to enable macros?". Very many thanks in advance, Aaron |
All times are GMT +1. The time now is 08:48 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com