Rick Danger
asked on
Can I specify a file to save using FileDialog SaveAs Code?
I want to allow my user to save a file using Office.FileDialog. Is it possible? I need to be able to specify the filename and initial directory
Yes, using the InitialFileName property, for example Application.FileDialog.Ini tialFileNa me = "c:\MyText.txt"
ASKER
But that's not telling me how to save the file. This is my code:
Dim strFolderPath As String
Dim fd As Office.FileDialog
Dim strPath As String
'Create a FileDialog object as a Folder Picker dialog box.
Set fd = Application.FileDialog(mso FileDialog FilePicker )
'Set strPath to the folder you want to open initially
strPath = "C:\Dropbox\"
With fd
.Filters.Clear
.Filters.Add "PDF Documents", "*.pdf"
.Title = "Browse for folder where you would like to save the PDF"
.ButtonName = "Save"
.InitialFileName = strPath
.InitialView = msoFileDialogViewDetails
If .Show = -1 Then
strFolderPath = CStr(fd.SelectedItems.Item (1)) & "\"
Else
MsgBox "You chose cancel"
strFolderPath = ""
End If
End With
SelectFolder = strFolderPath
So how do I change it to save a file please
Dim strFolderPath As String
Dim fd As Office.FileDialog
Dim strPath As String
'Create a FileDialog object as a Folder Picker dialog box.
Set fd = Application.FileDialog(mso
'Set strPath to the folder you want to open initially
strPath = "C:\Dropbox\"
With fd
.Filters.Clear
.Filters.Add "PDF Documents", "*.pdf"
.Title = "Browse for folder where you would like to save the PDF"
.ButtonName = "Save"
.InitialFileName = strPath
.InitialView = msoFileDialogViewDetails
If .Show = -1 Then
strFolderPath = CStr(fd.SelectedItems.Item
Else
MsgBox "You chose cancel"
strFolderPath = ""
End If
End With
SelectFolder = strFolderPath
So how do I change it to save a file please
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.