Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Kaua Costa   on Dec 06 In MS Office Category.

  
Question Answered By: Bradley Evans   on Dec 06

You have several choices depending on whether you want to save  a copy
of the workbook with a new name while retaining the name of the
current workbook to continue working on, or whether you simply want to
save as and keep on working on the newly named workbook.

Assuming the serial number  is in cell  A1 of the sheet which will have
the save button  on it:
Create this macro in a code module:

Sub blah()
On Error Resume Next
myPath = "C:\Documents and Settings\aUser\My Documents\"
ThisWorkbook.SaveAs myPath & ActiveSheet.Range("A1") & ".xls"
End Sub

making sure the myfolder line contains a valid path.

From the Forms toolbar add a button to the sheet, assign blah() to it.
Edit the text on the button to 'Save'.

To save only a copy as the new name and remain working on the original
substitute SaveCopyAs for SaveAs above.

To prevent checks such as 'A file  named ~ already exists.. ..Do you
want to replace it?' appearing you can add the lines beginning
Application.DisplayAlerts and lose the On Error line viz.:

Sub blah()
Application.DisplayAlerts = False
myPath = "C:\Documents and Settings\aUser\My Documents\"
ThisWorkbook.SaveAs myPath & ActiveSheet.Range("A1") & ".xls"
Application.DisplayAlerts = True
End Sub

This will always overwrite any existing file of the same name.

These are raw solutions with little error checking, so only add the On
Error line after you're sure it works.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on File save Or get search suggestion and latest updates.


Tagged: