Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save as problem

Status
Not open for further replies.

dezian

Technical User
Jul 29, 2003
21
GB
I would like some pointers relating to closing and saving an excel file please. If anyone could help, I use macros to input client details into specific cells, on exiting this file I want the file to be saved, but I want the file name to be called from a value in a seperate cell within another excel file, this is an order number relevent to each client. Any takers ?
 
To Save a workbook upon closing, go to the This Workbook object in the Microsoft Excel Objects section of the VBE Project Directory and enter:
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveWorkbook.SaveAs fName
End Sub
The variable "fName" will hold your new file name for the workbook.

Dan.
 
Please forgive me, for I do not understand the fName variable, what I need to do is take a number from a cell in another spread sheet and use it as the file name for the one that is to be saved !
 
Since I don't know what you will be using as a file name, I am using fName as an example. You would replace fName with whatever value you need to use for a file name.

Dan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top