Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro code behind button | Excel Worksheet Functions | |||
command button code | Excel Discussion (Misc queries) | |||
Add a Button Programatically plus code | Excel Discussion (Misc queries) | |||
VBA code for search button | Excel Worksheet Functions | |||
configure add button & code | Excel Discussion (Misc queries) |