getting save as file name in word
ms-word, save, vba
Solution
You can provide a default path including filename like so to the dialog, ie
Sub SaveName()
Dim strFileName As String
Dim StrPath As String
'provide default filename
StrPath = "c:\temp\test.docx"
With Dialogs(wdDialogFileSaveAs)
.Name = StrPath
If .Display <> 0 Then
strFileName = .Name
Else
strFileName = "User Cancelled"
End If
End With
MsgBox strFileName
End Sub
Problem
In the code below the file name is hard coded, but I want the user to be able to pick it. I was reading about `GetSaveAsFilename` but I get an error when using it: "method or member not found". ``` fileSaveName = Application.GetSaveAsFilename _ (fileFilter:="Excel Files (*.txt), *.txt") ``` This is written for Word 2010. Am I wrong in thinking `GetSaveAsFilename` is available in word VBA? ``` Sub Macro3() ' ' Macro3 Macro ' ' ActiveDocument.SaveAs2 FileName:="Questionnaire01-05-20122.txt", _ FileFormat:=wdFormatText, LockComments:=False, Password:="", _ AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _ EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _ :=True, SaveAsAOCELetter:=False, Encoding:=1252, InsertLineBreaks:=False, _ AllowSubstitutions:=False, LineEnding:=wdCRLF, CompatibilityMode:=0 End Sub ```