LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.misc
Norman Yuan
 
Posts: n/a
Default How to stop Excel remembering/loading macro from previously opened Workbook

OK, your suggestion seems my best bet. I was thinking on that direction, but
having not done coding my own toolbar/menu(CommandBar, I think it is) so
far, I thought that task would cost me more time than developing the macros.
So I asked here to see if there is a simple solution. Again, to me, it seems
not making sense that Excel's toolbar insists loading macro from previous
file, even though the macro is available in the current file. Thanks for the
suggestion and the links provided,

"Dave Peterson" wrote in message
...
Your life will become much simpler if you include code to create the
toolbar
when the workbook is opened and include code to destroy the toolbar when
the
workbook is closed.

For additions to the worksheet menu bar, I really like the way John
Walkenbach
does it in his menumaker workbook:
http://j-walk.com/ss/excel/tips/tip53.htm

Here's how I do it when I want a toolbar:
http://www.contextures.com/xlToolbar02.html
(from Debra Dalgleish's site)

Norman Yuan wrote:

I wrote several macros with VBA code for specific tasks, which works
well.
In order to for user to launch the macros easily, I created a custom
toolbar
and assigned each macro to a toolbar button. Thus, user can click a
button
to run a macro, instead of pressing ALT+F8 and then selecting a macro on
the
list.

This approach works well except for one thing: when user opens a new
Excel
work book from the customized template with the macro embedded in it (or
open a previous workbook and save it to a new file name), the toolbar
button
remembers previous workbook's name and load macro from that previous
file,
even though the same macros are available in this workbook. This causes
the
previously worked workbook being opened undesirably. Even worse, if the
previous workbook is not available (renamed, or moved, or deleted),
clicking
the toolbar button causes error message saying "xxxxxx.xls cannot be
found....". However, if user press ALT+F8 to run macro, Excel uses the
macro
in the file, as expected.

Does anyone know how to stop Toolbar Button to remember where the macro
is
loaded from? What is the point for Excel to remember the last file name
of a
macro and loads it from there even though the same macro is in current
workbook? The ideal situation is, after assign a macro to a toolbar
button.
It should only remembers macro's name. When being clicked, it should only
look into current workbook, if macro exists, run it, if macro does not
exist, report error message.


--

Dave Peterson





 
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
Macro that saves excel workbook as PDF?? mydogpeanut Excel Discussion (Misc queries) 1 May 25th 06 08:56 PM
Using a macro to create a macro in another workbook Gizmo63 Excel Worksheet Functions 2 May 15th 06 09:48 AM
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
How to run a macro as soon a a workbook (.xls) is opened? Sangamesh Acharya Excel Worksheet Functions 1 December 15th 05 11:15 PM
Urgent Help Required on Excel Macro Problem Sachin Shah Excel Discussion (Misc queries) 1 August 17th 05 06:26 AM


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