Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro names in a Module

I've found that assigning a macro to a toolbar control employs the
filename as a prefix to the macro name. EX: myfile.xls!macro1. If the
workbook is renamed or a copy made with a different name, the controls
will continue to look for the macro in the original file. Is there any
way to limit the assigned name to the macro name only?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro names in a Module

No, I believe not. part of the name is the location.

That said, I have never tried

something.OnAction = "!Macro1"

but I think that would prepend a name as well.

--
Regards,
Tom Ogilvy




wrote in message
oups.com...
I've found that assigning a macro to a toolbar control employs the
filename as a prefix to the macro name. EX: myfile.xls!macro1. If the
workbook is renamed or a copy made with a different name, the controls
will continue to look for the macro in the original file. Is there any
way to limit the assigned name to the macro name only?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Macro names in a Module

Another approach is to have the workbook create the control either on an
existing toolbar or a new toolbar when the workbook opens (and delete it
when the workbook closes)

Remember to add a delete to remove it all before you remake it.
Or check to see if it already exists before you remake it.

--
steveB

Remove "AYN" from email to respond
"Michel Pierron" wrote in message
...
Simply:
ThisWorkbook.Name & "!macro1"

MP

a écrit dans le message de news:
...
I've found that assigning a macro to a toolbar control employs the
filename as a prefix to the macro name. EX: myfile.xls!macro1. If the
workbook is renamed or a copy made with a different name, the controls
will continue to look for the macro in the original file. Is there any
way to limit the assigned name to the macro name only?





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro names in a Module


I once new a Steve Bell in Florida - any chance you're him

--
excelgurudumm
-----------------------------------------------------------------------
excelgurudummy's Profile: http://www.excelforum.com/member.php...fo&userid=2544
View this thread: http://www.excelforum.com/showthread.php?threadid=38998



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Macro names in a Module

I have family down there, but never lived there.

I originated in Washington, DC and am now in Oregon...

--
steveB

Remove "AYN" from email to respond
"excelgurudummy"
wrote in
message news:excelgurudummy.1ss5j5_1122387049.767@excelfor um-nospam.com...

I once new a Steve Bell in Florida - any chance you're him?


--
excelgurudummy
------------------------------------------------------------------------
excelgurudummy's Profile:
http://www.excelforum.com/member.php...o&userid=25441
View this thread: http://www.excelforum.com/showthread...hreadid=389983



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro names in a Module

I've tried this suggestion and it doesn't work. Other than substituting
single quotes for doubles in your suggestion, I've entered it exactly
as shown. When I access the button afterwards, the full directory path
has been added to " 'ThisWorkbook.Name&'!macro1". I've also tried
variations such as " 'ThisWorkbook.Name'!macro1 " as well as
subsituting the worksheet for "Name". Activating the control always
indicates "can't find macro". Any ideas what I'm doing wrong?

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro names in a Module

Okay, I finally got it! Part of the problem was that I was trying to
make the assignment Michael suggest from outside of Visual Basic. Not
gonna work!! Here's what I finally did.
I had already created an auto_open macro for something else. But
defining the button macros there works great. For each button on the
custom toolbar called "SBIC" I added a line like the following to
assign a Module-level macro.

CommandBars("SBIC").Controls("Vendor Order").OnAction = _
ThisWorkbook.Name & "!VendorOrder"

Now, changing the filename has no negative impact upon locating macros.

thanks for all the help. It's much appreciated.

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
Which macro module wal50 Excel Discussion (Misc queries) 4 March 17th 09 07:46 PM
macro to standard module Simon Excel Discussion (Misc queries) 9 May 17th 07 08:25 PM
Set Worksheet Names in a Module Noemi Excel Discussion (Misc queries) 1 July 20th 06 01:39 PM
Module Names within a Project WSF Excel Programming 2 May 15th 04 11:51 PM
Module Names Casey[_2_] Excel Programming 4 January 6th 04 11:03 PM


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

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"