PC Review


Reply
Thread Tools Rate Thread

assign macro - toolbar

 
 
bryan
Guest
Posts: n/a
 
      25th Mar 2009
I am re-asking this as I'm not getting any info back and project is needed.

I have a protected workbook template named Reinsurance.xlt which I assign a
macro to toolbar button, macro is called 'SaveToDrive'.
I created the toolbar and then used Commands, Macros, Cutom Button. Right
click on button to assign macro ' SaveToDrive'.

Macro saves as entry in cell A12.
Lets's say I enter 'BJS1' into this cell, it saves as BJS1.xls.
If I open the template and look at the assign macro,
it now says 'c:\BJS1.xls' ! SaveToDrive
not 'Reinsurance.xlt' !SaveToDrive.

The template save is written like this:
sFilename = "c:\" + strcell"
ActiveWorkbook.SaveAs Filename:=sFilename, _
FileFormat:=xlNormal, _
ReadOnlyRecommended:=False, _
CreateBackup:=False
Application.Quit
Application.StatusBar = "Application Closing."

Am I missing something on the save or am I doing something wrong in
assigning the macro?

I've used this same method in Word to save files and the macro never changes.


Thanks,
Bryan

 
Reply With Quote
 
 
 
 
Bernie Deitrick
Guest
Posts: n/a
 
      25th Mar 2009
When you do a SaveAs, Excel updates the reference to the macro. If you want to keep the reference
to the .xlt, then use

ActiveWorkbook.SaveCopyAs Filename:=sFilename, _ .....

instead.

But a better solution would be to either store the code in your personal.xls or use an add-in, with
additional code to make sure that only workbooks based on the specific template are saved using that
code.

HTH,
Bernie
MS Excel MVP


"bryan" <(E-Mail Removed)> wrote in message
news:5CE7712C-56E6-406E-BA08-(E-Mail Removed)...
>I am re-asking this as I'm not getting any info back and project is needed.
>
> I have a protected workbook template named Reinsurance.xlt which I assign a
> macro to toolbar button, macro is called 'SaveToDrive'.
> I created the toolbar and then used Commands, Macros, Cutom Button. Right
> click on button to assign macro ' SaveToDrive'.
>
> Macro saves as entry in cell A12.
> Lets's say I enter 'BJS1' into this cell, it saves as BJS1.xls.
> If I open the template and look at the assign macro,
> it now says 'c:\BJS1.xls' ! SaveToDrive
> not 'Reinsurance.xlt' !SaveToDrive.
>
> The template save is written like this:
> sFilename = "c:\" + strcell"
> ActiveWorkbook.SaveAs Filename:=sFilename, _
> FileFormat:=xlNormal, _
> ReadOnlyRecommended:=False, _
> CreateBackup:=False
> Application.Quit
> Application.StatusBar = "Application Closing."
>
> Am I missing something on the save or am I doing something wrong in
> assigning the macro?
>
> I've used this same method in Word to save files and the macro never changes.
>
>
> Thanks,
> Bryan
>



 
Reply With Quote
 
bryan
Guest
Posts: n/a
 
      25th Mar 2009
Thank you very much - works as expected.
The only thing I needed to change was using only:
ActiveWorkbook.SaveCopyAs Filename:=sFilename

I initially had the rest of the code in here but, compile error on
Fileformat:=

Is personal.xls like normal.dot in Word?

The macro will only be on certain xlt workbooks....

Thanks,
Bryan

"Bernie Deitrick" wrote:

> When you do a SaveAs, Excel updates the reference to the macro. If you want to keep the reference
> to the .xlt, then use
>
> ActiveWorkbook.SaveCopyAs Filename:=sFilename, _ .....
>
> instead.
>
> But a better solution would be to either store the code in your personal.xls or use an add-in, with
> additional code to make sure that only workbooks based on the specific template are saved using that
> code.
>
> HTH,
> Bernie
> MS Excel MVP
>
>
> "bryan" <(E-Mail Removed)> wrote in message
> news:5CE7712C-56E6-406E-BA08-(E-Mail Removed)...
> >I am re-asking this as I'm not getting any info back and project is needed.
> >
> > I have a protected workbook template named Reinsurance.xlt which I assign a
> > macro to toolbar button, macro is called 'SaveToDrive'.
> > I created the toolbar and then used Commands, Macros, Cutom Button. Right
> > click on button to assign macro ' SaveToDrive'.
> >
> > Macro saves as entry in cell A12.
> > Lets's say I enter 'BJS1' into this cell, it saves as BJS1.xls.
> > If I open the template and look at the assign macro,
> > it now says 'c:\BJS1.xls' ! SaveToDrive
> > not 'Reinsurance.xlt' !SaveToDrive.
> >
> > The template save is written like this:
> > sFilename = "c:\" + strcell"
> > ActiveWorkbook.SaveAs Filename:=sFilename, _
> > FileFormat:=xlNormal, _
> > ReadOnlyRecommended:=False, _
> > CreateBackup:=False
> > Application.Quit
> > Application.StatusBar = "Application Closing."
> >
> > Am I missing something on the save or am I doing something wrong in
> > assigning the macro?
> >
> > I've used this same method in Word to save files and the macro never changes.
> >
> >
> > Thanks,
> > Bryan
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assign Macro to Icon on toolbar HomeTaught Microsoft Excel Misc 3 15th Jan 2010 01:21 AM
How to re-assign macro to Toolbar or Menu? aushknotes Microsoft Word Document Management 7 3rd Apr 2008 12:39 AM
re-assign macro to toolbar =?Utf-8?B?S2Vybm93IEdpcmw=?= Microsoft Word Document Management 1 15th Aug 2006 03:26 PM
Assign Recurring Macro to Toolbar NICK Microsoft Excel Misc 1 26th Feb 2004 04:22 AM
Assign Macro to Toolbar Problem Neill Wood Microsoft Excel Misc 0 9th Jul 2003 11:51 AM


Features
 

Advertising
 

Newsgroups
 


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