cancel
Showing results for 
Search instead for 
Did you mean: 

Load From XML

Former Member
0 Kudos

Hello...

I am using the following function to load a form from xml, I found this function here in forum, not mine, BUUUUT when trying runing the function I got:

"ERROR: Form - Reserved / Illegal form Unique ID"

I tryed change form name a bunch of times, but keep getting error.

If someone could help me I would be glad.


 Private Function LoadXMLForm(ByVal sFile As String) As Boolean
        Try
            Dim oXMLDoc As MSXML2.DOMDocument
            Dim oCreationParams As SAPbouiCOM.FormCreationParams
            Dim s As String
            Try
                s = "c:/FormSample_simple.srf"
                oXMLDoc = New MSXML2.DOMDocument
                oXMLDoc.load(s)
                oCreationParams = oapplication.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)
                oCreationParams.XmlData = oXMLDoc.xml
                oApplication.Forms.AddEx(oCreationParams)
                Return True
            Catch e As Exception
                oApplication.MessageBox("Error: " & e.Message)
                Return False
            End Try
            System.Runtime.InteropServices.Marshal.ReleaseComObject(oCreationParams)
            System.Runtime.InteropServices.Marshal.ReleaseComObject(oXMLDoc)
        Catch ex As Exception
            oApplication.MessageBox("Error: " & ex.Message)
        End Try
        GC.Collect()
    End Function

Accepted Solutions (1)

Accepted Solutions (1)

rasmuswulff_jensen
Active Contributor

Try to add this line

oCreationParams.UniqueID = "formUid"

after

oCreationParams.XmlData = oXMLDoc.xml

Problem must be that the xml you load have a invalid Unique (Is the xml-form a system form?)

Answers (2)

Answers (2)

Former Member
0 Kudos

So.... ^^ It worked.. btw.. i did it in screen painter.. i was double declaring the form @@ one loading from xml and another "code-generated" and I was triggering the visible for the code-generated...

thanks for you all anyway.

Former Member
0 Kudos

ok... thnks... its loaded, BUUUT, loaded a blank form ^^ and only when i add this line.... sorry for my newb questions, but i am new to this stuff....


oform = oapplication.Forms.AddEx(oCreationParams)
                oform.Visible = True

Message was edited by: Fernando Mendes Weffort

rasmuswulff_jensen
Active Contributor
0 Kudos

Where did you get the XML-file from... try pasting a small part of it here