导出时MS Access VBA冻结/崩溃



下面几行是用于生成XML的代码的摘录。

Access 2010冻结,然后在执行Set dlgSaveAs行时崩溃。这种情况似乎只有在使用.xls文件导入数据时才会发生,.csv文件似乎工作正常。

请不要查看代码有什么问题,以及为什么它不能与.xls/.xlsx文件一起使用。

        Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
        With dlgSaveAs
            .InitialFileName = strDate & " " & Replace(strTime, ":", "") & " " & strFFI_Filename & " XML Export" & ".xml" 'Set the default filename and directory
            .InitialView = msoFileDialogViewDetails 'Set the default folder view
            .Title = "Please provide a file name" 'Set your own dialog title
        End With

您尝试过执行以下操作吗?

With Application.FileDialog(msoFileDialogSaveAs)
        .InitialFileName = strDate & " " & Replace(strTime, ":", "") & " " & strFFI_Filename & " XML Export" & ".xml" 'Set the default filename and directory
        .InitialView = msoFileDialogViewDetails 'Set the default folder view
        .Title = "Please provide a file name" 'Set your own dialog title
End With

显然,与dlgSaveAs相关的任何其他代码都需要在with End with

中移动

最新更新