View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default VBA code for Excel File Save As

You can use GetSaveAsFilename

Sub Test()
Dim fname As Variant
Dim Wb As Workbook
Set Wb = ActiveWorkbook

fname = Application.GetSaveAsFilename("", _
fileFilter:="Excel Files (*.xls), *.xls")
If fname < False Then
Wb.SaveAs fname
'Wb.Close False
Set Wb = Nothing
Else
Set Wb = Nothing
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"khlaudhya" wrote in message ...
Hi,

I'm building a code where at some point I need to save the file to a new location with a specific file name, which is also

specified by the code. I would like to be prompted for this but it only saves if I specify the path.

This is the bit I have already written and can't go further:

Dim NewName As String

NewName = mRateName & " " & Validade & ".xls"

If MsgBox("Save file as " & NewName & "?", vbYesNo, Save) = vbNo Then

Exit Sub

ActiveWorkbook.SaveAs FileName:=NewName

Can anyone help me?

Thanks