问题
I have written a VBA macro to load and parse an XML file. This exact code has worked fine for awhile, but now it's no longer functioning. I've tested it on two different computers running Excel 2013 64-bit. The code it fails on is below:
Public Sub RunClashImport()
'This subroutine will import an XML clash report, parse it, and write it to our workbook
Dim iRow As Integer
'Get XML file
Dim xmlFile As MSXML2.DOMDocument60
Set xmlFile = New MSXML2.DOMDocument60
The code continues if I comment out the Set command. It doesn't throw an error, it crashes Excel entirely. The code above is where the macro starts, there is no code running before it. I have set a reference to v6.0 of MSXML
回答1:
For a 64 bit Windows OS you should put your msxml6.dll inside of C:\Windows\SysWOW64
and then register it from that location, by running this command in your command prompt regsvr32.exe C:\Windows\SysWOW64\msxml6.dll
.
Make sure that you run you command prompt as Administrator.
来源:https://stackoverflow.com/questions/21717778/msxml2-domdocument60-crashes-excel