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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Default SaveAs file name 1

Status
Not open for further replies.

ballbearing

Technical User
Jan 7, 2004
43
US
I hope this question hasn't been answered more than 27 times before (probably has..but gotta ask anyway)

How should I code this?

In C:\Files\ I have:
book1.xls
book2.xls
book3.xls

How do I have it save to book4.xls automatically using code?

Thanks
Randy

Gawd I love this Access stuff..too bad I don't know what I'm doing.
 
Assuming that the Files folder contains only sequentially numbered Books....

Sub Name_file()
Dim X As Integer
Dim New_File_Name As String
SourceFolder = "C:\Files\"
Set fso = CreateObject("Scripting.FileSystemObject")
X = fso.GetFolder(SourceFolder).Files.Count
New_File_Name = "Book" + trim(CStr(X + 1)) + ".xls"
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top