导入XML崩溃Excel [英] Importing XML Crashes Excel

查看:249
本文介绍了导入XML崩溃Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的所有电子表格中遇到了这个反复出现的问题。电子表格将工作正常,并导入从我们的网站抓取的xml文件,然后突然它将开始崩溃每次导入。修复它的唯一的事情是把所有的内容(工作表,代码,引用),并把它们放到一个新的工作簿。

I have had this recurring problem with all of my spreadsheets for months. The spreadsheet will be working fine and importing the xml files fetched from our website, then all of a sudden it will start crashing everytime on import. The only thing that fixes it is to take all of the contents (sheets, code, references) and drop them into a fresh workbook.

这是它崩溃的行。

ActiveWorkbook.XmlImport URL:=l_strXMLFileName, _
ImportMap:=Nothing, Destination:=Sheets("Imported Data").Range("$A$1")

有没有这个问题?

推荐答案

我发现这个问题后,我发现答案只是因为这对我来说是一个灾难,并且困扰了我好几个月。希望这篇文章会阻止别人像我这么久的拉起他们的头发。

I posted this question after I found the answer just because this was such a disaster for me, and had plagued me for months. Hopefully this post will keep someone else from pulling their hair out like I did for so long.

这个修复很简单。发生什么是每次excel导入一个xml文件,它在该电子表格中存储一个xmlmap。因此,如果您使用相同的电子表格并保存,它们会随时间累积。我找到的最好的解决方案是删除这些xml地图,或重用相同的(后者不是一个好的选择很多次)。

The fix is pretty simple. What happens is every time excel imports an xml file, it stores an xmlmap in that spreadsheet. So if you use the same spreadsheet and keep saving it, these build up over time. The best solution I have found is to just delete these xml maps, or reuse the same one (the latter is not a good option many times).

这里是一些代码删除所有这些(我只是在我的问题中包含的代码之前运行):

Here is some code to delete all of them (I just run this before the code I included in my question):

Dim XmlMap as XmlMap
    For Each XmlMap In ActiveWorkbook.XmlMaps
        XmlMap.Delete
    Next

这篇关于导入XML崩溃Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆