I got this code from a forum and it works but I need to tweak it to show me the "save as" box but I with the name already populated with my variable FName.
Can someone help me with this?
Sub Save_New()
Dim FName As String
Dim FPath As String
'FPath = "C:"
FName = Sheets("Sheet1").Range("A1").Text
ThisWorkbook.SaveAs Filename:=FName
End Sub
You can use the Application.GetSaveAsFilename method for that …
Option Explicit
Sub Save_New()
Dim FName As String
FName = Sheets("Sheet1").Range("A1").Text
Dim DialogResult As Variant 'variant is needed because the dialog returns FALSE if users presses cancel.
DialogResult = Application.GetSaveAsFilename(InitialFilename:=FName)
If Not DialogResult = False Then
ThisWorkbook.SaveAs Filename:=DialogResult
Else
'user clicked cancel
End If
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.