Bob*_*Bob 1 ms-access vba openfiledialog ms-access-2010
我试图让文件对话框弹出,以便用户可以选择一个文件路径以在 VBA 中导出文件,但由于某种原因,它会在以下代码行中引发此错误。
错误:对象“_Application”的方法“FileDialog”失败
代码: longResult = Application.FileDialog(msoFileDialogFolderPicker).Show
所有代码:
If choice = 6 Then
Dim intResult As Long
Dim strPath As String
'the dialog is displayed to the user
longResult = Application.FileDialog(msoFileDialogFolderPicker).Show
'checks if user has cancled the dialog
If intResult <> 0 Then
'dispaly message box
Call MsgBox(Application.FileDialog(msoFileDialogFolderPicker _
).SelectedItems(1), vbInformation, "Selected Folder")
End If
Else
End
End If
Run Code Online (Sandbox Code Playgroud)
我真的不确定如何解决这个问题。我检查了我的语法和一切。
小智 6
我知道这在这一点上是一个老问题,但由于它实际上没有答案,而我今天需要一个,我将补充我发现的内容,以防其他人需要也回答。
要解决此问题,您需要在Visual Basic 编辑器 >> 工具 >> 参考...中添加对“Microsoft Office [您的版本] 对象库”的引用。
有问题的对话框应如下所示:
| 归档时间: |
|
| 查看次数: |
8740 次 |
| 最近记录: |