No file when Save As is executed
The application.getsaveasfilename has a parameter that can be used to specify
the initial name (if you want to "suggest" a name to the user).
If you don't want to suggest a name at all, you can use:
fFilter = "Excel Files (*.xls), *.xls"
SaveName = Application.GetSaveAsFilename(InitialFileName:="", _
fileFilter:=fFilter)
And if you want to let excel suggest what it wants to suggest:
fFilter = "Excel Files (*.xls), *.xls"
SaveName = Application.GetSaveAsFilename(fileFilter:=fFilter)
uriel78 wrote:
I've got a question on this argument...How can I do to obtain a routine
similar to the one you posted, which allows me to enter the name of the file
in the same way I do when I choose "save as" from Fyle menu.. instead of
typing it in the macro
I mean I need sthg to subsitute the line
NewName = "P2 LogHistory Shift"
with a call for the windows displaying "save as"...
Thanks in advance
"Dave Peterson" ha scritto nel messaggio
...
This line:
SaveName = Application.GetSaveAsFilename _
(NewName, fileFilter:=fFilter)
only returns the name of the file the user chose--it doesn't do the actual
save.
Sub RenameFilenameUponClose()
Dim SaveName As variant '<--changed
Dim fFilter As String
Dim NewName As String
NewName = "P2 LogHistory Shift"
fFilter = "Excel Files (*.xls), *.xls"
SaveName = Application.GetSaveAsFilename _
(NewName, fileFilter:=fFilter)
if savename = false then
'use cancelled--what to do?
else
thisworkbook.saveas filename:=savename,
fileformat:=xlworkbooknormal
end if
End Sub
--
Dave Peterson
|