简体   繁体   English

MS Access VBA在导出时冻结/崩溃

[英]MS Access VBA freeze/crash on Export

The lines below are an extract from code used to generate a XML. 下面的几行是用于生成XML的代码的摘录。

Access 2010 freezes then crashes when executing the Set dlgSaveAs line. 执行Set dlgSaveAs行时,Access 2010冻结,然后崩溃。 This seems to only happen when data is imported using .xls files, .csv's seem to work fine. 这似乎仅在使用.xls文件导入数据时才会发生,.csv似乎可以正常工作。

Don't see what's wrong with the code and why it doesn't work with .xls/.xlsx files. 没有看到代码有什么问题以及为什么它不适用于.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

Have you tried doing the following? 您是否尝试过以下操作?

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

Obviously any other code associated with dlgSaveAs would need moving in the With-End With block 显然,与dlgSaveAs相关的任何其他代码都需要在With-End With块中移动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM