LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
nx3 nx3 is offline
external usenet poster
 
Posts: 8
Default VBA assign macro to button from a different file (simple you'd thi

I have to modify 2000 files so I've written a master file that loops through
a list, importing modules and forms into the 2000 files it opens and closes.
On each file when open it draws a button on worksheet. I then want to assign
a macro to the button called "ModifyMenu" . The code for 'Modifymenu' is
imported into file_01.xls and is a unique name. It does not exist is
master.xls, so no confusion.

The code for assigning the code is as follows :

Windows("file_01.xls").Activate
ActiveSheet.Shapes("Button").Select
or
Workbooks("file_01.xls").Sheets("1 B").Shapes("Button").Select


Then

Selection.OnAction = "ModifyMenu"
(This links to master.xls!ModifyMenu not file_01.xls)

Selection.OnAction = "file_01.xls!ModifyMenu"
(This fails, runtime 1004. 'Unable to set the OnAction property of the
button class)

Selection.OnAction = ThisWorkbook.Name & "!ModifyMenu"
(This links to master. MAster is the active code even though 'file_01.xls'
is the active worksheet)

Variations on the above seem to result in the same 1004 error or linking
back to master regardless of the fact I'm trying to link to file_01.xls.

Any help much appricated.
Regards
Nick

 
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
Assign a macro to a button totofab Excel Discussion (Misc queries) 4 December 13th 07 06:16 PM
Button assign macro breaks with file name change and appears elsew Student Excel Discussion (Misc queries) 2 July 25th 06 09:06 PM
How do I Assign Macro to a button? BellExcel Charts and Charting in Excel 4 May 20th 05 07:21 PM
Assign macro to button Frank Kabel Excel Programming 0 May 24th 04 04:03 PM
Assign button to run macro jamie85[_5_] Excel Programming 8 February 3rd 04 01:44 PM


All times are GMT +1. The time now is 12:11 PM.

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"