S
SDecou
I found this code, but am receiving an error on this line Call
existingDataFields.parentNode.replaceChild(newDataFields.cloneNode(True),
existingDataFields). Could someone please help me. I think I have it dimmed
incorrectly.
Public Sub ClearForm()
'load the template xml that is generated by the Designer
Dim domTemplate As New MSXML2.DOMDocument
domTemplate = CreateObject("MSXML2.DomDocument.5.0")
domTemplate.async = False
domTemplate.validateOnParse = False
domTemplate.load("template.xml")
If domTemplate Is Nothing Then
MsgBox("Could not load the template!")
Else
'Get the ITT Node in the form's DOM
Dim existingDataFields As MSXML2.IXMLDOMNode
existingDataFields =
thisXDocument.DOM.selectSingleNode("/dfs:myFields")
Call domTemplate.setProperty("SelectionNamespaces",
"xmlns:dfs=""http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"""
& "
xmlns:d=""http://schemas.microsoft.com/office/infopath/2003/ado/dataFields""")
'Replace with node from loaded XML template.
Dim newDataFields As MSXML2.IXMLDOMNode
newDataFields = domTemplate.selectSingleNode("/dfs:myFields")
Call
existingDataFields.parentNode.replaceChild(newDataFields.cloneNode(True),
existingDataFields)
MsgBox("finished")
End If
End Sub
existingDataFields.parentNode.replaceChild(newDataFields.cloneNode(True),
existingDataFields). Could someone please help me. I think I have it dimmed
incorrectly.
Public Sub ClearForm()
'load the template xml that is generated by the Designer
Dim domTemplate As New MSXML2.DOMDocument
domTemplate = CreateObject("MSXML2.DomDocument.5.0")
domTemplate.async = False
domTemplate.validateOnParse = False
domTemplate.load("template.xml")
If domTemplate Is Nothing Then
MsgBox("Could not load the template!")
Else
'Get the ITT Node in the form's DOM
Dim existingDataFields As MSXML2.IXMLDOMNode
existingDataFields =
thisXDocument.DOM.selectSingleNode("/dfs:myFields")
Call domTemplate.setProperty("SelectionNamespaces",
"xmlns:dfs=""http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"""
& "
xmlns:d=""http://schemas.microsoft.com/office/infopath/2003/ado/dataFields""")
'Replace with node from loaded XML template.
Dim newDataFields As MSXML2.IXMLDOMNode
newDataFields = domTemplate.selectSingleNode("/dfs:myFields")
Call
existingDataFields.parentNode.replaceChild(newDataFields.cloneNode(True),
existingDataFields)
MsgBox("finished")
End If
End Sub