Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Enz Enz is offline
external usenet poster
 
Posts: 21
Default Assigning macro buttons to macro code in another file

Thanks Dave for your suggestion. I made the changes you suggested and
it worked perfectly the first time. Much appreciated.

regards,
Enzo

On May 25, 1:13*pm, Dave Peterson wrote:
How about an alternative that will make life lots easier?

Instead of using buttons from the forms toolbar and assigning macros to them,
how about using commandbuttons from the Control Toolbox toolbar.

Since your code is in the sheet module anyway, there wouldn't be much of a
change (since the code will travel with the copied worksheet when it's placed
into the new workbook).

But it will require some changes.





Enz wrote:

Hello


Does anyone know if you can do the following?


I coded a macro that creates several tabs within it (call it
Executive), each of which contains a button to invoke a macro (and
each sheet has its' own macro code). *Then I create an output file
that copies the desired tabs from Executive to a new Workbook output
file. *I am currently coding the portion of the Executive macro where
I am re-assigning the existing button in each tab to point to the
macro code within the output file sheets, that I am attempting to
create. *The output file will be run independently from the
originating Executive macro file, so I need the output file to
reference only macro code within itself.


When I attempt to specify the output file name when assigning the
button to execute the macro code within the new Workbook output macro
file, I get a run time error '1004' *'Unable to set the OnAction
property of the Button Class'. *I believe I am getting this message
because the button class does not allow you to specify another file
reference when assigning macro code to buttons outside the current
macro executing. *Can anyone confirm my belief? *Or perhaps I have an
error I am not yet seeing.


This is the logic that attempts to re-assign the macro code to
reference the logic in the output file


'Note that this index is referencing the Executive workbook but will
be the same number in the output workbook
'Note "Desk Output" is the new workbook that contains the subroutine
CopyLogs in each worksheet tab


lcurrentDate = Format(Date, " yyyy mmm d")
lindex = ThisWorkbook.Sheets(ActiveSheet.Name).Index
ActiveSheet.Shapes("Button 3").Select
Selection.OnAction = "Desk Output " & lcurrentDate & "!Sheet" & lindex
& ".CopyLogs"


I have validated all the variables and I believe I have the correct
values as it stands if this were to work.


Any thoughts would be greatly appreciated.


Regards,
* Enz


--

Dave Peterson- Hide quoted text -

- Show quoted text -


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
in vb, what is the 1-line code of assigning a macro using click ExcelSuperUser Excel Programming 3 September 26th 07 06:52 PM
Assigning Macro by using code Bob Phillips Excel Programming 1 January 9th 07 07:31 PM
Creating Buttons and assigning code winshent Excel Programming 3 July 14th 04 09:14 AM
Assigning a Macro to a Shockwave File Chris Hankin Excel Programming 2 June 23rd 04 09:51 AM
Assigning Macro to "Buttons" grin2000[_5_] Excel Programming 2 June 9th 04 02:53 PM


All times are GMT +1. The time now is 09:17 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"