Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default assign macro - toolbar

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default assign macro - toolbar

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" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default assign macro - toolbar

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" wrote in message
...
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
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 Macro to Icon on toolbar HomeTaught Excel Discussion (Misc queries) 3 January 15th 10 01:21 AM
Excel 2003 - assign macro to custom toolbar button Candace Excel Discussion (Misc queries) 1 August 10th 09 12:14 PM
Assign macro to WB-specific toolbar button? Ian Excel Programming 6 March 2nd 07 10:11 PM
Assign ShortCut-key To Toggle VBA-toolbar? SIGE Excel Programming 4 April 19th 05 04:45 PM
Assign macro to toolbar custom button? amescha Excel Programming 5 September 27th 04 05:31 PM


All times are GMT +1. The time now is 06:52 AM.

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"