Web Development

General discussion


Provide filename to SaveAs dialog in Excel VBA

By chris.bezant ·
Is it possible to call the SaveAs dialog from Excel VBA and prefill the filename?

Any guidance would be most appreciated.

Chris Bezant

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

Excel VBA to prefill filename in SaveAs

by linda.hasa In reply to Provide filename to SaveA ...

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.

' 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
ThisFile = Range("A1").Value
FileDrive = "C:\FOLDERNAME\"
ActiveWorkbook.SaveAs Filename:=FileDrive & ThisFile & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub

Collapse -

Similar Problem

by mriordan25 In reply to Excel VBA to prefill file ...

I want to create a command button taht when pressed saves the worksheet to a pre-determined location with a predetermined name accompanied by that day's date. The sheet will be saved daily so that the next day the user just opens the original file. It is driving me demented as nothing seems to work. I have got code from the internet but it generates errors every time. Can anyone help me with a simple step by step method?

Collapse -

use x dialog tricks

by crivet In reply to Provide filename to SaveA ...

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

Related Discussions

Related Forums