Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro code behind button bcm2 Excel Worksheet Functions 1 January 13th 10 06:13 PM
command button code dummy Excel Discussion (Misc queries) 2 December 1st 09 02:57 PM
Add a Button Programatically plus code jlclyde Excel Discussion (Misc queries) 1 December 9th 08 04:29 PM
VBA code for search button Dylan @ UAFC[_2_] Excel Worksheet Functions 3 November 25th 08 10:59 PM
configure add button & code [email protected] uk Excel Discussion (Misc queries) 7 November 24th 08 02:34 PM


All times are GMT +1. The time now is 09:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"