【问题标题】:giving the choice to my user to choose where he wants to save his file access让我的用户选择他想要保存文件访问的位置
【发布时间】:2020-07-13 16:32:21
【问题描述】:

我的问题是关于打开文档文件。 我想让我的用户选择他想要保存文件的位置。 但是,我可能错了,但我使用了 FileDialog (msoFileDialogFolderPicker) 正常打开文件,然后向我发送错误消息!我开始编程谢谢你的帮助。

这是我的代码

Public Function ObtenirCheminFichier(path As String)
    Dim fso As Object
    Dim filePath As String
    Set fso = CreateObject("scripting.filesystemobject")
    ObtenirCheminFichier = path

    If Not fso.FileExists(path) Then
        Dim tmpPath As String
        tmpPath = Replace(Replace(path, ".\", "", , 1), "\", "", 1, 0)
        'ObtenirCheminFichier = Application.FileDialog(msoFileDialogFolderPicker).Show()
      ' ObtenirCheminFichier = CurrentProject.path & "\" & tmpPath
         ObtenirCheminFichier = Application.FileDialog(msoFileDialogFolderPicker) & "\" & tmpPath
    End If
End Function

我怀疑这个错误

DoCmd.OutputTo acOutputQuery, "Categorie_C2_req", acSpreadsheetTypeExcel12, spath, True

【问题讨论】:

    标签: ms-access vba


    【解决方案1】:

    在文件夹选择器之后添加.SelectedItems(1),如下所示: Application.FileDialog(msoFileDialogFolderPicker).SelectedItems(1)

    有关 FileDialog 对象的更多详细信息,您可以查看API

    由于您要打开单个文件,我建议您在打开文件对话框之前添加此行:Application.FileDialog(msoFileDialogFolderPicker).AllowMultiSelect = False

    【讨论】:

      猜你喜欢
      • 2014-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-19
      相关资源
      最近更新 更多