Provide filename to SaveAs dialog in Excel VBA
Is it possible to call the SaveAs dialog from Excel VBA and prefill the filename?
Any guidance would be most appreciated.
Regards
Chris Bezant
Web Development
Is it possible to call the SaveAs dialog from Excel VBA and prefill the filename?
Any guidance would be most appreciated.
Regards
Chris Bezant
by linda hasa
I use the following where there is a concatenated file name in cell A1 of the selected sheet. Ignor the message box which just tells the user that the save to folder must already exist.
Sub SaveMYORDERFILE()
'
' SavePIDS Macro
' Macro recorded 9/15/2003 by Linda Hasa
'
MsgBox "Your C drive must contain a folder/directory named " & _
"'C:\FOLDERNAME\' before this macro can be executed. If necessary, " & _
"please cancel this macro and create an ORDERS folder on " & _
"your C drive before continuing. " & _
"" & _
"You may cancel this SAVE macro when prompted with a " & _
"'RUN-TIME ERROR' by pressing the END button."
'
With Application
.DefaultFilePath = "C:"
End With
Sheets("YourSheetName").Select
ThisFile = Range("A1").Value
FileDrive = "C:\FOLDERNAME\"
ActiveWorkbook.SaveAs Filename:=FileDrive & ThisFile & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Range("A1").Select
End Sub
by mriordan25
by crivet
Had the same problem, found your request and no answer so i had to try on my own, turns out it is easy:
Application.Dialogs(xlDialogSaveAs).Show "write the text you want as a predefined name here"
hope this helps
This discussion is closed to new replies.
Sort by Trending