我使用以下代码保存文件,但我无法获取保存的文件路径和名称。
有没有办法获取这些细节?
Sub Test3()
On Error Resume Next
Dim FileSelected As String
Dim strPath As String
FileSelected = Application.Dialogs(xlDialogSaveAs).Show
If Not FileSelected <> "False" Then
MsgBox "You have cancelled"
Exit Sub
End If
If FileSelected <> "False" Then
strPath = Application.FileDialog(msoFileDialogSaveAs).SelectedItems(1)
'displays the result in a message box
Call MsgBox(strPath, vbInformation, "Save Path")
Exit Sub
End If
End Sub
答案 0 :(得分:0)
尝试使用Application.GetSaveAsFilename
。创建Variant
变量,并在保存后将其设置为Application.GetSaveAsFilename
。