PDA

View Full Version : Solved: Save with file name issue



Desert Piranha
08-15-2005, 08:58 PM
Hi,
This code works fine but i want to change it.
Sub SaveAsTo()
Application.ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "\" & ActiveWorkbook.Name & Format(Date, "mm-dd-yyyy") & ".xls"
End Sub
It saves the file 'Test' as
IE 'Test.xls08-15-2005.xls'
What i am trying to do is get the .xls out
IE 'Test 08-15-2005.xls'

I know its a no brainer but i am having a senior moment.
I don't want to hard code the path/filename.

Thx
Dave

geekgirlau
08-15-2005, 09:11 PM
Sub SaveAsTo()
Application.ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "\" & _
Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) & " " & _
Format(Date, "mm-dd-yyyy") & ".xls"
End Sub

Steiner
08-15-2005, 11:00 PM
Just a small hint: Instead of
ActiveWorkbook.Path & "\" & ActiveWorkbook.Name

you can use
ActiveWorkbook.FullName
(Should also help when the file is in the root directory).

Daniel

geekgirlau
08-15-2005, 11:24 PM
Hey, nice one Daniel! :clap2:

Desert Piranha
08-16-2005, 03:41 PM
GdDay geekgirlau,

Thx for the responce Works fine.

Dave

P.S.Thx Steiner for the wisdom.
D.H.





Sub SaveAsTo()Application.ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "\" & _




Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) & " " & _
Format(Date, "mm-dd-yyyy") & ".xls"
End Sub