Assign macro

B

bryan

I have a template which has a toolbar button. The buton was assigned macro to
macro - SaveToDrive.
The save macro uses cell A12 to saveas name.
This is a template so each new instance of the xls is blank.
On first i enter 'BJS1' in A12 and the run macro, saves as A12.xls to my c:
drive and closes.
If I delete BJS1.xls and open new and enter 'BJS2' in A12 and save I get
message
'BJS1.xls' could not be found.
If I then open the template and look to see macro assigned to button it has
'BJS1.xls' assigned and not 'SaveTo Drive'.

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 am protecting the sheet and the workbook.
Thanks,
Bryan
 
M

Mike H

Hi,

I don't understand entirely the question your asking but what is clear is
that this line of code is incorrect

sFilename = "c:" + strcell"

on the assumption strcell is assigned a value somewhere the correct suntax is

sFilename = "c:\" & strcell

Mike
 
B

bryan

My typo, the '\' is in the sFilename.

I assign a macro to toolbar button, macro is called 'SaveToDrive'. It saves
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 'BJS1.xls'
not 'SaveToDrive'.
The macro assigned to the button is changing.....

Thanks,
Bryan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top