MSXML:无效的类字符串

时间:2012-03-28 16:45:09

标签: xml xslt vb6 macros msxml

我已安装在我的电脑上 MSXML 2.6 MSXML 3.0 MSXML 4.0 MSXML 6.0

当我尝试在执行时解析我的XSL时,我有错误无效的类字符串 这些是代码

Public Sub PreviewDOCUMENT()
    Dim ObjXMLTransformDoc
    Dim ObjXMLTransformStyle
    Dim ObjXMLDoc
    Dim ObjXMLStyle
    Dim ObjXsltSettings
    On Error GoTo ERR_HANDLER

    If mResultPath <> "" Then

        Set ObjXMLTransformDoc = CreateObject("Msxml2.DOMDocument.4.0")
        ObjXMLTransformDoc.Load (mResultPath & MyDocument.DOC_TYPE & "_XML_TO_XSL.xml")

        Set ObjXMLTransformStyle = CreateObject("Msxml2.DOMDocument.4.0")
        ObjXMLTransformStyle.Load ActiveWorkbook.path & "\RESULT\form_generation.xsl"

        ObjXMLTransformStyle.setProperty "AllowXsltScript", True

        Set ObjXMLStyle = CreateObject("Msxml2.DOMDocument.4.0")
        ObjXMLTransformDoc.transformNodetoObject ObjXMLTransformStyle, ObjXMLStyle

        KillFile mResultPath & MyDocument.DOC_TYPE & "_DOCUMENT_STYLE.xsl"
        DoEvents
        AppendToTextFile mResultPath & MyDocument.DOC_TYPE & "_DOCUMENT_STYLE.xsl", ObjXMLStyle.XML


        Dim mSE As New CShellExecute
        mSE.LaunchDocument 0, mResultPath & MyDocument.DOC_TYPE & "_XML_TO_XML.xml", ActiveWorkbook.path & "\RESULT\", sesSW_SHOWDEFAULT
    Else
        MsgBox "Create documents first!"
    End If
Exit Sub

ERR_HANDLER:
  MsgBox "Error: " & Err.Number & ". " & Err.Description

End Sub

1 个答案:

答案 0 :(得分:1)

据我记得,默认加载是异步的,因此为了使您的代码序列有意义,您需要在ObjXMLTransformDoc.async = False加载调用之前添加ObjXMLTransformDoc.Load并在{{之前添加ObjXMLTransformStyle.async = False 1}}打电话。 您获得的错误消息是否与我相关,但我不确定。你能告诉我们你得到错误的确切陈述或行吗?