Button, but now code

  • Thread starter Thread starter Aaron Fude
  • Start date Start date
A

Aaron Fude

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
 
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
(e-mail address removed)
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
 
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)
 

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

Back
Top