我正在尝试按照 http://software-solutions-online.com/excel-vba-save-file-dialog-getsaveasfilename/ 此处的教程进行操作,并将我的代码输入为:
varResult = Application.GetSaveAsFilename(FileFilter:="Excel Files (*.xlsx), *.xlsx")
现在,当我编译语法时,出现以下错误:
在这个特定元素上
GetSaveAsFilename
我在 Access 2013 中运行它以保存 Excel 2013 .xlsx - 我应该更改什么以便提示用户输入保存名称和位置?
最佳答案
此特定方法在 Access VBA 中不起作用。 (VBA 在 Office 产品之间不能 100% 互换。)
Access VBA 中的示例:
Sub TestFileDialog()
'requires Reference to "Microsoft Office xx.x Object Library"
Dim strFilename As String
With Application.FileDialog(msoFileDialogSaveAs)
If .Show Then
strFilename = .SelectedItems(1)
Else
MsgBox "No filename specified!", vbExclamation
Exit Sub
End If
End With
'do something with strFilename
End Sub
这应该适用于从 Access 保存 Excel 对象。
关于excel - Excel VBA中的文件保存对话框,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47965766/