MS Access Runtime - 文件对话框失败

MS Access Runtime - File Dialog fails

我希望你能帮助我... 我在 MS Access 2013 (.accdb) 中有一个应用程序。单击按钮时我有一个文件对话框功能。 (MSGBOX函数是调试用的!)

Private Sub Browse_btn_Click()
Dim path As String, initialPath As String
Dim fd As Object
MsgBox "Function Starts"
On Error GoTo errhnd

If IsNull(Me.RPE_Txt.value) Then initialPath = "C:\users\" & Environ("USERNAME") & "\" _
    Else: initialPath = Me.RPE_Txt.value

MsgBox "Setting FD"
Set fd = Application.FileDialog(3)



On Error GoTo errhnd

With fd
        MsgBox "in fd with statement"
        .Title = "RPE File"
        MsgBox "fd.initialview"
        .InitialView = 2
        .AllowMultiSelect = False
        .Filters.Clear
        .Filters.Add "Excel Files", "*.csv"
        .InitialFileName = initialPath
        MsgBox "show"
        .Show
        MsgBox "path"
        path = .SelectedItems(1)
End With
MsgBox "end with"
Me.RPE_Txt.value = path

Exit Sub
errhnd:
MsgBox Err.Description, vbCritical, "Error: " & Err.Number

End Sub

当我 运行 在 MS Access Runtime 2010 上执行此操作时,我在单击按钮时遇到标准运行时错误并且 Access 崩溃...

我尝试使用以下代码添加引用,但尝试时崩溃了..

If Application.Version = 14# Then
    MsgBox "Office 2010"
    If Dir("C:\Program Files\Common Files\microsoft shared\OFFICE14\MSO.DLL") <> "" And Not refExists("OFFICE") Then
        MsgBox "Applying Reference for 2010 Office"
        'Application.References.AddFromFile "C:\Program Files\Common Files\microsoft shared\OFFICE14\MSO.dll"
        Application.References.AddFromGuid "{398E906A-826B-48DD-9791-549C649CACE5}", 14#, 14#
        MsgBox "Office 2010 Reference Applied!"
    End If

ElseIf Application.Version = 15# Then
    MsgBox "Office 2013"
    If Dir("C:\Program Files\Common Files\microsoft shared\OFFICE15\MSO.dll") <> "" And Not refExists("OFFICE") Then
        MsgBox "Applying Reference for 2013 Office"
        Application.References.AddFromFile "C:\Program Files\Common Files\microsoft shared\OFFICE15\MSO.dll"
        MsgBox "Office 2013 Reference Applied!"
    End If

End If

如有任何帮助,我们将不胜感激!

谢谢, 皮特!

遗憾的是,FileDialog 在运行时不起作用。

可以在此处找到经常引用的替换代码:

API: Call the standard Windows File Open/Save dialog box

虽然冗长,但确实有效。