Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Create button with addin/reference macro in another file

OK, I have a program that references an addin and runs the code in that. At a point, the adding creates a button and then adds the onaction property to it. The problem I am having is that I need that line of code to somehow reference a module of code in the active workbook. The workbook name will never be the same and I can get the name of the workbook no problem and put that into a variable, but when I put the variable on that line of code, it compiles fine but when it runs, it errors out

What I have done

Dim WBK As Workboo
Dim MacroName As Strin
Set WBK = ActiveWorkboo
MacroName = """" & WBK.Name & "!run_final" & """

Then I create the button and attach the macro

Selection.OnAction = MacroNam

But it will always error out when the code is executed

Stumped......Any help would be greatly appreciated!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Create button with addin/reference macro in another file

get rid of """""

MacroName = """" & WBK.Name & "!run_final" & """"

should be

MacroName = WBK.Name & "!run_final"

MacroName holds the string: Book1.xls!run_final

the way you are doing it is is holding the string "Book1.xls!run_final"

so the quotes become part of the name (which doesn't exist).

--
Regards,
Tom Ogilvy




"netzig" wrote in message
...
OK, I have a program that references an addin and runs the code in that.

At a point, the adding creates a button and then adds the onaction property
to it. The problem I am having is that I need that line of code to somehow
reference a module of code in the active workbook. The workbook name will
never be the same and I can get the name of the workbook no problem and put
that into a variable, but when I put the variable on that line of code, it
compiles fine but when it runs, it errors out.

What I have done:

Dim WBK As Workbook
Dim MacroName As String
Set WBK = ActiveWorkbook
MacroName = """" & WBK.Name & "!run_final" & """"

Then I create the button and attach the macro:

Selection.OnAction = MacroName

But it will always error out when the code is executed.

Stumped......Any help would be greatly appreciated!!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Create button with addin/reference macro in another file

I tried that and it also failed, can you think of anything else that I might be missing?
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
Create A Button and Assign A Macro To It carl Excel Worksheet Functions 2 November 8th 11 08:30 PM
Create a button with a macro vba franco monte New Users to Excel 0 March 7th 10 07:53 PM
How can I create a button in Macro (2007 XL) Iraj Excel Worksheet Functions 0 March 6th 09 11:59 AM
Create button to run Macro? Joe M. Excel Discussion (Misc queries) 3 June 3rd 08 02:17 PM
How to reference MSNStockQuote button within a macro tfrentz Excel Worksheet Functions 2 February 26th 07 03:13 PM


All times are GMT +1. The time now is 12:07 AM.

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

About Us

"It's about Microsoft Excel"