我正在尝试在 Excel 中获取一张表并使用 VBA 创建一个 XML 文档,然后使用 XSLT 样式表转换该文档。
我已经包含了下面的代码,直到我遇到问题为止。
当我尝试像这样创建一个对象时:
Dim transformer As XslCompiledTransform ' transform document
我收到此错误:
Compile Error: User defined type - not defined
我以前在定义时遇到过这个错误
Dim objDom As DOMDocument
但是引用这个问题为我解决了这个问题。但是,对于这种情况,我找不到类似的东西。
有人可以向我解释是否有我需要包含的参考以及将来如何找到这些参考吗?
注意:我在 Excel 2003 中使用 Visual Basic 编辑器来创建这个 VBA 宏
Sub CreateXML()
'Variable to hold all rows in excel file
Dim rows As Variant
'Variables used to iterate through row array
Dim i As Integer
Dim j As Integer
'Create objects for manipulating XML
Dim objDom As DOMDocument
Dim objXMLRootelement As IXMLDOMElement
Dim objXMLelement As IXMLDOMElement
Dim objXMLattr As IXMLDOMAttribute
'Represents the top level of the XML source
Set objDom = New DOMDocument
'~~> Creates root element
Set objXMLRootelement = objDom.createElement("Project")
objDom.appendChild objXMLRootelement
'~~> Saves XML data to a file
objDom.Save ("C:\Users\JSLAMKIN\Desktop\test.xml")
'Create an instance of the DOMDocument class:
Dim xDoc As DOMDocument
Set xDoc = New DOMDocument
'Create the file as output
Dim output As DOMDocument
Dim transformer As XslCompiledTransform ' transform document
...