MSXML: Invalid Class String

I have installed on my computer MSXML 2.6 MSXML 3.0 MSXML 4.0 MSXML 6.0

when i try to parse my XSL at runtime i have an Invalid Class String error this is the code

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"
        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
        MsgBox "Create documents first!"
    End If
Exit Sub

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

End Sub



source to share

1 answer

As far as I remember, loading is asynchronous by default, so for your code sequence, you need to add ObjXMLTransformDoc.async = False

before the load call ObjXMLTransformDoc.Load

and ObjXMLTransformStyle.async = False

before the call ObjXMLTransformStyle.Load

. Whether I'm getting an error related to something I'm not sure about. Can you tell us the exact operator or line where you are getting this error?



All Articles