VBA Code :-
Dim objSuggestion As XMLChildNodeSuggestion
Dim objNode As XMLNode
Set objNode = Selection.XMLNodes.Item(1)
For Each objSuggestion In objNode.ChildNodeSuggestions
objSuggestion.Insert
Selection.MoveRight
Next
C# Code :-
public void XmlChildCollection()
{
Word.XMLChildNodeSuggestion wordXmlChildNodeCollection = null;
Word.XMLNodes objNode = null;
int i =1;
objNode = ThisApplication.Selection.XMLNodes ;
foreach (Word.XMLChildNodeSuggestions wordXmlChild in objNode)
{
object objitem = i;
Word.Range wordrange = ThisApplication.Selection.Range;
object obj = wordrange;
wordXmlChild.get_Item(ref objitem).Insert(ref obj);
i++;
}
}
VBA Code :-
Sub ApplySampleSchema()
Dim objSchema As XMLNamespace
For Each objSchema In Application.XMLNamespaces
If objSchema.URI = "SimpleSample" Then
objSchema.AttachToDocument ActiveDocument
Exit For
End If
Next
End Sub
C# Code :-
public void ApplySampleSchema()
{
Word.XMLNamespaces objschema = ThisApplication.XMLNamespaces;
foreach (Word.XMLNamespace objSchema in objschema)
{
if (objSchema.URI == "SimpleSample")
{
object activeDocument = ThisApplication.ActiveDocument;
objSchema.AttachToDocument(ref activeDocument);
}
}
}
VBA Code :-
Dim objNode As XMLNode
For Each objNode In ActiveDocument.XMLNodes
objNode.Validate
If objNode.ValidationStatus <> wdXMLValidationStatusOK Then
MsgBox objNode.ValidationErrorText(True)
End If
Next
C# Code :-
public void XmlNodes()
{
Word.XMLNode objNode = null;
foreach (Word.XMLNode xmlnode in ThisApplication.ActiveDocument.XMLNodes)
{
if (xmlnode.ValidationStatus != Microsoft.Office.Interop.Word.WdXMLValidationStatus.wdXMLValidationStatusOK)
{
object objTrue = true;
xmlnode.SetValidationError(Microsoft.Office.Interop.Word.WdXMLValidationStatus.wdXMLValidationStatusOK, ref objTrue, true);
}
}
}
VBA Code :-
Dim objNode As XMLNode
Dim intResponse As Integer
Set objNode = Selection.XMLNodes.Add("example", "SimpleSample")
objNode.Validate
If objNode.ValidationStatus < 0 Then
intResponse = MsgBox("This element is invalid. " & _
"Are you sure you want to add it?", vbYesNo)
If intResponse = vbNo Then objNode.Delete
End If
C# Code :-
public void XmlNodes()
{
Word.XMLNodes xmlNodes = ThisApplication.ActiveDocument.XMLNodes;
Word.XMLNode xmlNode = ThisApplication.ActiveDocument.XMLNodes[1];
string stgrName = "example";
string strnamespace = "SimpleSample";
xmlNode = ThisApplication.Selection.XMLNodes.Add(stgrName, strnamespace, ref missing);
xmlNode.Validate();
if (xmlNode.ValidationStatus < 0)
{
}
}
VBA Code :-
Sub VerifySampleSchema()
Dim objNS As XMLNamespace
Dim objSchema As XMLSchemaReference
Dim blnSchemaAttached As Boolean
For Each objSchema In ActiveDocument.XMLSchemaReferences
If objSchema.NamespaceURI <> "SimpleSample" Then
blnSchemaAttached = False
Else
objSchema.Reload
blnSchemaAttached = True
Exit For
End If
Next
If blnSchemaAttached = False Then
Set objNS = Application.XMLNamespaces.Item("SimpleSample")
objNS.AttachToDocument (ActiveDocument)
End If
End Sub
C# Code :-
public void BerifySampleSchema()
{
bool myvalue = false;
foreach (Word.XMLSchemaReference xmlRef in ThisApplication.ActiveDocument.XMLSchemaReferences)
{
if (xmlRef.NamespaceURI != "SimpleSample")
{
myvalue = true;
}
else
{
myvalue = false;
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment