FILE 'SAVE AS' IN VBA CODE

S

Sally

Hi,
Please can someone tell me the VBA code to prompt a user to 'save as' a file
in excel. the folders will have to be specified...
 
B

Bob Phillips

Look at GetSaveAsFilename in VBA help.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
C

Chip Pearson

Try code like

Dim FName As Variant
FName = Application.GetSaveAsFilename(ThisWorkbook.Name, "Excel
Files (*.xls),*.xls")
If FName = False Then
MsgBox "User Clicked Cancel"
Else
ThisWorkbook.SaveAs Filename:=FName
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
J

JLatham

Something similar to this should work

Sub FileSaveAsCode()

Dim fName As Variant

fName = Application.GetSaveAsFilename( _
fileFilter:="Excel Workbooks (*.xls), *.xls")
If fName = "" Then ' user [Cancel]ed
Exit Sub
End If

On Error Resume Next
ActiveWorkbook.SaveAs Filename:=fName
If Err <> 0 Then
'user probably cancelled at this point
'as when notified of existing file of same name
'you can either test for errors
'or simply ignore them
Err.Clear
End If
 
Top