Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Help saving workbook

I need a VBA resolution to save a workbook as a certain name.

EX: I have workbook ONE.XLS open and need it to be saved as ONE082508A.XLS
where "ONE" is the original name, "082508" is the date it is being saved and
"A" is derived from a cell within the workbooks, say cell A1.

Can someone please help me with this?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 257
Default Help saving workbook

This isn't too hard. Start by looking up the Workbook.SaveAs method; it'll
tell you the syntax for saving a workbook under a different name, in a
different format, with a password, all that stuff. In the end you'll
probably make it a simple call like

MyWorkbook.SaveAs NewName

....where NewName is a variable into which you've constructed the new
workbook name. As for how to set up that name, I suggest when saving it as a
file name you use yymmdd rather than mmddyy; the files sort much better that
way. Up to you, though. Your program must get the current name of the
workbook, add on the date and then add on the value of A1. If it were me,
I'd do it like this:

NewName = MyWorkbook.Name
ip = pos(NewName, ".")
NewName = Left(NewName, ip - 1)
NewName = NewName & Format(Date, "yymmdd") & Range("A1").Value
NewName = NewName & ".xls"

....or something like that. You'd have to consider the path, too, if you
didn't want it stored in the default folder.

--- "Russ Morgan" wrote:
I need a VBA resolution to save a workbook as a certain name.

EX: I have workbook ONE.XLS open and need it to be saved as ONE082508A.XLS
where "ONE" is the original name, "082508" is the date it is being saved and
"A" is derived from a cell within the workbooks, say cell A1.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help saving workbook


With ThisWorkbook
BName = .Name
BaseName = Left(BName, Len(BName) - 4)
MyDate = Format(Date, "MMDDYY")
NewName = BaseName & MyDate & ".xls"
.SaveAs Filename:=.Path & "\" & NewName
End With

"Russ Morgan" wrote:

I need a VBA resolution to save a workbook as a certain name.

EX: I have workbook ONE.XLS open and need it to be saved as ONE082508A.XLS
where "ONE" is the original name, "082508" is the date it is being saved and
"A" is derived from a cell within the workbooks, say cell A1.

Can someone please help me with this?



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
Color Changes When Saving 2007 Workbook as 97 - 2003 Workbook Don Excel Discussion (Misc queries) 0 April 20th 08 04:51 AM
Saving Workbook yasser Excel Programming 1 October 27th 06 01:00 AM
Saving a sheet in a workbook as .csv but not changing workbook name gloryofbach[_4_] Excel Programming 3 October 30th 05 08:50 PM
Saving a Workbook: Forcing User to Rename before Saving Rollin_Again[_6_] Excel Programming 5 April 16th 04 02:54 PM
Saving workbook gav meredith Excel Programming 2 April 14th 04 06:29 AM


All times are GMT +1. The time now is 10:28 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"