Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Calling the wrong macro

Hi Folks,
Any help with this would be much appreciated:
I have two workbooks created in Excel 2000, Book A and Book B
Both work books contain a macro which have the same name: MyMacro1

MyMacro1 contains different code in each workbook
When I call MyMacro1 in Book A, Excel opens Workbook B and runs the code
within the Book B - MyMacro1

I can't figure out why this happening - has anyone any ideas please?
I've tried deleting both macros and recreating them independently - to no
avail!

TIA

Philip


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Calling the wrong macro

I guess it depends on what you mean by Call MyMacro1. If you are doing it
with a menu button, then it is tied to a specifice macro - probably the one
in workbook B.

--
Regards,
Tom Ogilvy

"Philip" wrote in message
news:A6Sed.19054$Pl.17748@pd7tw1no...
Hi Folks,
Any help with this would be much appreciated:
I have two workbooks created in Excel 2000, Book A and Book B
Both work books contain a macro which have the same name: MyMacro1

MyMacro1 contains different code in each workbook
When I call MyMacro1 in Book A, Excel opens Workbook B and runs the code
within the Book B - MyMacro1

I can't figure out why this happening - has anyone any ideas please?
I've tried deleting both macros and recreating them independently - to no
avail!

TIA

Philip




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Calling the wrong macro

Thanks Tom,
Yes, you're right, I'm calling it from a toolbar button - I guess that must
make a difference. So I suppose my question should really be: How do I make
a toolbar and it's associated macros launced specific to a Workbook.

I've tried playing around with it but having created a toolbar it seems to
appear in all Workbooks? That suprises me a little

Thanks again for replying - I appreciate your help

Regards

Philip

"Tom Ogilvy" wrote in message
news:dtTed.113212$Lo6.75092@fed1read03...
I guess it depends on what you mean by Call MyMacro1. If you are doing it
with a menu button, then it is tied to a specifice macro - probably the

one
in workbook B.

--
Regards,
Tom Ogilvy

"Philip" wrote in message
news:A6Sed.19054$Pl.17748@pd7tw1no...
Hi Folks,
Any help with this would be much appreciated:
I have two workbooks created in Excel 2000, Book A and Book B
Both work books contain a macro which have the same name: MyMacro1

MyMacro1 contains different code in each workbook
When I call MyMacro1 in Book A, Excel opens Workbook B and runs the code
within the Book B - MyMacro1

I can't figure out why this happening - has anyone any ideas please?
I've tried deleting both macros and recreating them independently - to

no
avail!

TIA

Philip






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Calling the wrong macro

Toolbars are at the application level. When you assign a macro to the
toolbar, it includes the specific workbook that contains the macro and this
does not change (nor does it adjust if you move that workbook outside of
excel). You would need to add code in the workbook activate event for the
specific workbooks where you want that behavior, that reassigns the macro --
assign the button's onaction property to the macro in that workbook.

--
Regards,
Tom Ogilvy

"Philip" wrote in message
news:FKVed.19982$Pl.3636@pd7tw1no...
Thanks Tom,
Yes, you're right, I'm calling it from a toolbar button - I guess that

must
make a difference. So I suppose my question should really be: How do I

make
a toolbar and it's associated macros launced specific to a Workbook.

I've tried playing around with it but having created a toolbar it seems to
appear in all Workbooks? That suprises me a little

Thanks again for replying - I appreciate your help

Regards

Philip

"Tom Ogilvy" wrote in message
news:dtTed.113212$Lo6.75092@fed1read03...
I guess it depends on what you mean by Call MyMacro1. If you are doing

it
with a menu button, then it is tied to a specifice macro - probably the

one
in workbook B.

--
Regards,
Tom Ogilvy

"Philip" wrote in message
news:A6Sed.19054$Pl.17748@pd7tw1no...
Hi Folks,
Any help with this would be much appreciated:
I have two workbooks created in Excel 2000, Book A and Book B
Both work books contain a macro which have the same name: MyMacro1

MyMacro1 contains different code in each workbook
When I call MyMacro1 in Book A, Excel opens Workbook B and runs the

code
within the Book B - MyMacro1

I can't figure out why this happening - has anyone any ideas please?
I've tried deleting both macros and recreating them independently - to

no
avail!

TIA

Philip








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Calling the wrong macro

Thanks Tom, I'd kinda hoped that it would work in much the same way as MS
Word - but it obviously doesn't
You have saved me from wasting a lot more of time though - thanks again.

Philip


"Tom Ogilvy" wrote in message
...
Toolbars are at the application level. When you assign a macro to the
toolbar, it includes the specific workbook that contains the macro and

this
does not change (nor does it adjust if you move that workbook outside of
excel). You would need to add code in the workbook activate event for the
specific workbooks where you want that behavior, that reassigns the

macro --
assign the button's onaction property to the macro in that workbook.

--
Regards,
Tom Ogilvy

"Philip" wrote in message
news:FKVed.19982$Pl.3636@pd7tw1no...
Thanks Tom,
Yes, you're right, I'm calling it from a toolbar button - I guess that

must
make a difference. So I suppose my question should really be: How do I

make
a toolbar and it's associated macros launced specific to a Workbook.

I've tried playing around with it but having created a toolbar it seems

to
appear in all Workbooks? That suprises me a little

Thanks again for replying - I appreciate your help

Regards

Philip

"Tom Ogilvy" wrote in message
news:dtTed.113212$Lo6.75092@fed1read03...
I guess it depends on what you mean by Call MyMacro1. If you are

doing
it
with a menu button, then it is tied to a specifice macro - probably

the
one
in workbook B.

--
Regards,
Tom Ogilvy

"Philip" wrote in message
news:A6Sed.19054$Pl.17748@pd7tw1no...
Hi Folks,
Any help with this would be much appreciated:
I have two workbooks created in Excel 2000, Book A and Book B
Both work books contain a macro which have the same name: MyMacro1

MyMacro1 contains different code in each workbook
When I call MyMacro1 in Book A, Excel opens Workbook B and runs the

code
within the Book B - MyMacro1

I can't figure out why this happening - has anyone any ideas please?
I've tried deleting both macros and recreating them independently -

to
no
avail!

TIA

Philip












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
calling macro in a formula rk0909 Excel Discussion (Misc queries) 2 March 14th 06 04:15 PM
calling excel macro TommyBoy Excel Programming 0 August 12th 04 10:25 PM
calling a dll from excel macro Stefan[_4_] Excel Programming 1 December 12th 03 12:16 AM
calling a macro from within a loop Rick[_12_] Excel Programming 1 July 30th 03 11:52 PM
Calling macro in add-in. Clark B Excel Programming 1 July 24th 03 11:05 PM


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