导出时MS Access VBA冻结/崩溃

时间:2015-07-02 10:15:35

标签: excel vba ms-access

以下行是用于生成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

1 个答案:

答案 0 :(得分:0)

您是否尝试过以下操作?

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