Function SetDataValue(strXML As String)
Dim MyXmlDoc As MSXML2.DOMDocument40
Dim XmlNode As MSXML2.IXMLDOMNode
On Error Resume Next
ActiveDocument.Shapes("Txt_xml").TextFrame.TextRange.Text = strXML
Set MyXmlDoc = New MSXML2.DOMDocument40
MyXmlDoc.async = False
If MyXmlDoc.LoadXML(strXML) Then
Set XmlNode = MyXmlDoc.SelectSingleNode("/TemplateData/Common/DocClass")
If Not (XmlNode Is Nothing) Then
SetDocClass XmlNode.Text
End If
Set XmlNode = MyXmlDoc.SelectSingleNode("/TemplateData/Special/Stock/TradeName")
If Not (XmlNode Is Nothing) Then
SetIndustry XmlNode.Text
End If
Set XmlNode = MyXmlDoc.SelectSingleNode("/TemplateData/Common/Title")
If Not (XmlNode Is Nothing) Then
SetTitle XmlNode.Text
End If
Set XmlNode = MyXmlDoc.SelectSingleNode("/TemplateData/Special/Stock/InvestRating")
If Not (XmlNode Is Nothing) Then
SetEst XmlNode.Text
End If
Set XmlNode = MyXmlDoc.SelectSingleNode("/TemplateData/Special/Stock/TargetPrice")
If Not (XmlNode Is Nothing) Then
SetTargetPrice XmlNode.Text
End If
Set XmlNode = MyXmlDoc.SelectSingleNode("/TemplateData/Common/CreateTime")
If Not (XmlNode Is Nothing) Then
SetDate XmlNode.Text
End If
Set XmlNode = MyXmlDoc.SelectSingleNode("/TemplateData/Common/Author")
If Not (XmlNode Is Nothing) Then
SetAnalyst XmlNode.Text
End If
Else
Application.StatusBar = "数据格式错误,无法填充。"
End If
SetTitle "dingwei2009"
SetDataValue = "cg"
End Function
SetDocClass ,SetTitle 之类都是 设置word文档的值,但是读取xml却是null,代码能编译,在windows service 2012 上 是什么问题