diff --git a/Examples/CSharp/CSharp.csproj b/Examples/CSharp/CSharp.csproj
index 30bc5ac27..6d84b85dc 100644
--- a/Examples/CSharp/CSharp.csproj
+++ b/Examples/CSharp/CSharp.csproj
@@ -98,6 +98,11 @@
+
+
+
+
+
diff --git a/Examples/CSharp/Programming-Documents/Fields/InsertASKFieldWithOutDocumentBuilder.cs b/Examples/CSharp/Programming-Documents/Fields/InsertASKFieldWithOutDocumentBuilder.cs
new file mode 100644
index 000000000..242ca202f
--- /dev/null
+++ b/Examples/CSharp/Programming-Documents/Fields/InsertASKFieldWithOutDocumentBuilder.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections;
+using System.IO;
+
+using Aspose.Words;
+using Aspose.Words.Tables;
+using Aspose.Words.Fields;
+using Aspose.Words.Layout;
+
+namespace CSharp.Programming_Documents.Working_with_Fields
+{
+ class InsertASKFieldWithOutDocumentBuilder
+ {
+ public static void Run()
+ {
+ //ExStart:InsertASKFieldWithOutDocumentBuilder
+ // The path to the documents directory.
+ string dataDir = RunExamples.GetDataDir_WorkingWithFields();
+ Document doc = new Document(dataDir + "in.doc");
+ // Get paragraph you want to append this Ask field to
+ Paragraph para = (Paragraph)doc.GetChildNodes(NodeType.Paragraph, true)[1];
+
+ // We want to insert an Ask field like this:
+ // { ASK \"Test 1\" Test2 \\d Test3 \\o }
+
+ // Create instance of FieldAsk class and lets build the above field code
+ FieldAsk field = (FieldAsk)para.AppendField(FieldType.FieldAsk, false);
+
+ // { ASK \"Test 1\" " }
+ field.BookmarkName = "Test 1";
+
+ // { ASK \"Test 1\" Test2 }
+ field.PromptText = "Test2";
+
+ // { ASK \"Test 1\" Test2 \\d Test3 }
+ field.DefaultResponse = "Test3";
+
+ // { ASK \"Test 1\" Test2 \\d Test3 \\o }
+ field.PromptOnceOnMailMerge = true;
+
+ // Finally update this Ask field
+ field.Update();
+
+ dataDir = dataDir + "InsertASKFieldWithOutDocumentBuilder_out_.doc";
+ doc.Save(dataDir);
+
+ //ExEnd:InsertASKFieldWithOutDocumentBuilder
+ Console.WriteLine("\nASK field without using document builder inserted successfully.\nFile saved at " + dataDir);
+ }
+ }
+}
diff --git a/Examples/CSharp/Programming-Documents/Fields/InsertAdvanceFieldWithOutDocumentBuilder.cs b/Examples/CSharp/Programming-Documents/Fields/InsertAdvanceFieldWithOutDocumentBuilder.cs
new file mode 100644
index 000000000..4f3a7d295
--- /dev/null
+++ b/Examples/CSharp/Programming-Documents/Fields/InsertAdvanceFieldWithOutDocumentBuilder.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections;
+using System.IO;
+
+using Aspose.Words;
+using Aspose.Words.Tables;
+using Aspose.Words.Fields;
+using Aspose.Words.Layout;
+
+namespace CSharp.Programming_Documents.Working_with_Fields
+{
+ class InsertAdvanceFieldWithOutDocumentBuilder
+ {
+ public static void Run()
+ {
+ //ExStart:InsertAdvanceFieldWithOutDocumentBuilder
+ // The path to the documents directory.
+ string dataDir = RunExamples.GetDataDir_WorkingWithFields();
+ Document doc = new Document(dataDir + "in.doc");
+ // Get paragraph you want to append this Advance field to
+ Paragraph para = (Paragraph)doc.GetChildNodes(NodeType.Paragraph, true)[1];
+
+ // We want to insert an Advance field like this:
+ // { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 \\x 100 \\y 100 }
+
+ // Create instance of FieldAdvance class and lets build the above field code
+ FieldAdvance field = (FieldAdvance)para.AppendField(FieldType.FieldAdvance, false);
+
+
+ // { ADVANCE \\d 10 " }
+ field.DownOffset = "10";
+
+ // { ADVANCE \\d 10 \\l 10 }
+ field.LeftOffset = "10";
+
+ // { ADVANCE \\d 10 \\l 10 \\r -3.3 }
+ field.RightOffset = "-3.3";
+
+ // { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 }
+ field.UpOffset = "0";
+
+ // { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 \\x 100 }
+ field.HorizontalPosition = "100";
+
+ // { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 \\x 100 \\y 100 }
+ field.VerticalPosition = "100";
+
+ // Finally update this Advance field
+ field.Update();
+
+ dataDir = dataDir + "InsertAdvanceFieldWithOutDocumentBuilder_out_.doc";
+ doc.Save(dataDir);
+
+ //ExEnd:InsertAdvanceFieldWithOutDocumentBuilder
+ Console.WriteLine("\nAdvance field without using document builder inserted successfully.\nFile saved at " + dataDir);
+ }
+ }
+}
diff --git a/Examples/CSharp/Programming-Documents/Fields/InsertAuthorField.cs b/Examples/CSharp/Programming-Documents/Fields/InsertAuthorField.cs
new file mode 100644
index 000000000..7dac473ea
--- /dev/null
+++ b/Examples/CSharp/Programming-Documents/Fields/InsertAuthorField.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections;
+using System.IO;
+
+using Aspose.Words;
+using Aspose.Words.Tables;
+using Aspose.Words.Fields;
+using Aspose.Words.Layout;
+
+namespace CSharp.Programming_Documents.Working_with_Fields
+{
+ class InsertAuthorField
+ {
+ public static void Run()
+ {
+ //ExStart:InsertAuthorField
+ // The path to the documents directory.
+ string dataDir = RunExamples.GetDataDir_WorkingWithFields();
+ Document doc = new Document(dataDir + "in.doc");
+ // Get paragraph you want to append this AUTHOR field to
+ Paragraph para = (Paragraph)doc.GetChildNodes(NodeType.Paragraph, true)[1];
+
+ // We want to insert an AUTHOR field like this:
+ // { AUTHOR Test1 }
+
+ // Create instance of FieldAuthor class and lets build the above field code
+ FieldAuthor field = (FieldAuthor)para.AppendField(FieldType.FieldAuthor, false);
+
+ // { AUTHOR Test1 }
+ field.AuthorName = "Test1";
+
+ // Finally update this AUTHOR field
+ field.Update();
+
+ dataDir = dataDir + "InsertAuthorField_out_.doc";
+ doc.Save(dataDir);
+ //ExEnd:InsertAuthorField
+ Console.WriteLine("\nAuthor field without document builder inserted successfully.\nFile saved at " + dataDir);
+ }
+ }
+}
diff --git a/Examples/CSharp/Programming-Documents/Fields/InsertMailMergeAddressBlockFieldUsingDOM.cs b/Examples/CSharp/Programming-Documents/Fields/InsertMailMergeAddressBlockFieldUsingDOM.cs
new file mode 100644
index 000000000..fae227c07
--- /dev/null
+++ b/Examples/CSharp/Programming-Documents/Fields/InsertMailMergeAddressBlockFieldUsingDOM.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections;
+using System.IO;
+
+using Aspose.Words;
+using Aspose.Words.Tables;
+using Aspose.Words.Fields;
+using Aspose.Words.Layout;
+
+namespace CSharp.Programming_Documents.Working_with_Fields
+{
+ class InsertMailMergeAddressBlockFieldUsingDOM
+ {
+ public static void Run()
+ {
+ //ExStart:InsertMailMergeAddressBlockFieldUsingDOM
+ // The path to the documents directory.
+ string dataDir = RunExamples.GetDataDir_WorkingWithFields();
+ Document doc = new Document(dataDir + "in.doc");
+ DocumentBuilder builder = new DocumentBuilder(doc);
+
+ // Get paragraph you want to append this merge field to
+ Paragraph para = (Paragraph)doc.GetChildNodes(NodeType.Paragraph, true)[1];
+
+ // Move cursor to this paragraph
+ builder.MoveTo(para);
+
+ // We want to insert a mail merge address block like this:
+ // { ADDRESSBLOCK \\c 1 \\d \\e Test2 \\f Test3 \\l \"Test 4\" }
+
+ // Create instance of FieldAddressBlock class and lets build the above field code
+ FieldAddressBlock field = (FieldAddressBlock)builder.InsertField(FieldType.FieldAddressBlock, false);
+
+ // { ADDRESSBLOCK \\c 1" }
+ field.IncludeCountryOrRegionName = "1";
+
+ // { ADDRESSBLOCK \\c 1 \\d" }
+ field.FormatAddressOnCountryOrRegion = true;
+
+ // { ADDRESSBLOCK \\c 1 \\d \\e Test2 }
+ field.ExcludedCountryOrRegionName = "Test2";
+
+ // { ADDRESSBLOCK \\c 1 \\d \\e Test2 \\f Test3 }
+ field.NameAndAddressFormat = "Test3";
+
+ // { ADDRESSBLOCK \\c 1 \\d \\e Test2 \\f Test3 \\l \"Test 4\" }
+ field.LanguageId = "Test 4";
+
+ // Finally update this merge field
+ field.Update();
+
+ dataDir = dataDir + "InsertMailMergeAddressBlockFieldUsingDOM_out_.doc";
+ doc.Save(dataDir);
+
+ //ExEnd:InsertMailMergeAddressBlockFieldUsingDOM
+ Console.WriteLine("\nMail Merge address block field using DOM inserted successfully.\nFile saved at " + dataDir);
+ }
+ }
+}
diff --git a/Examples/CSharp/Programming-Documents/Fields/InsertMergeFieldUsingDOM.cs b/Examples/CSharp/Programming-Documents/Fields/InsertMergeFieldUsingDOM.cs
new file mode 100644
index 000000000..d81813dab
--- /dev/null
+++ b/Examples/CSharp/Programming-Documents/Fields/InsertMergeFieldUsingDOM.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections;
+using System.IO;
+
+using Aspose.Words;
+using Aspose.Words.Tables;
+using Aspose.Words.Fields;
+using Aspose.Words.Layout;
+
+namespace CSharp.Programming_Documents.Working_with_Fields
+{
+ class InsertMergeFieldUsingDOM
+ {
+ public static void Run()
+ {
+ //ExStart:InsertMergeFieldUsingDOM
+ // The path to the documents directory.
+ string dataDir = RunExamples.GetDataDir_WorkingWithFields();
+ Document doc = new Document(dataDir + "in.doc");
+ DocumentBuilder builder = new DocumentBuilder(doc);
+
+ // Get paragraph you want to append this merge field to
+ Paragraph para = (Paragraph)doc.GetChildNodes(NodeType.Paragraph, true)[1];
+
+ // Move cursor to this paragraph
+ builder.MoveTo(para);
+
+ // We want to insert a merge field like this:
+ // { " MERGEFIELD Test1 \\b Test2 \\f Test3 \\m \\v" }
+
+ // Create instance of FieldMergeField class and lets build the above field code
+ FieldMergeField field = (FieldMergeField)builder.InsertField(FieldType.FieldMergeField, false);
+
+ // { " MERGEFIELD Test1" }
+ field.FieldName = "Test1";
+
+ // { " MERGEFIELD Test1 \\b Test2" }
+ field.TextBefore = "Test2";
+
+ // { " MERGEFIELD Test1 \\b Test2 \\f Test3 }
+ field.TextAfter = "Test3";
+
+ // { " MERGEFIELD Test1 \\b Test2 \\f Test3 \\m" }
+ field.IsMapped = true;
+
+ // { " MERGEFIELD Test1 \\b Test2 \\f Test3 \\m \\v" }
+ field.IsVerticalFormatting = true;
+
+ // Finally update this merge field
+ field.Update();
+
+ dataDir = dataDir + "InsertMergeFieldUsingDOM_out_.doc";
+ doc.Save(dataDir);
+
+ //ExEnd:InsertMergeFieldUsingDOM
+ Console.WriteLine("\nMerge field using DOM inserted successfully.\nFile saved at " + dataDir);
+ }
+ }
+}
diff --git a/Examples/CSharp/RunExamples.cs b/Examples/CSharp/RunExamples.cs
index e58856dc4..83740608f 100644
--- a/Examples/CSharp/RunExamples.cs
+++ b/Examples/CSharp/RunExamples.cs
@@ -140,6 +140,11 @@ public static void Main()
//ChangeLocale.Run();
//UpdateDocFields.Run();
//InsertField.Run();
+ //InsertMergeFieldUsingDOM.Run();
+ //InsertMailMergeAddressBlockFieldUsingDOM.Run();
+ //InsertAdvanceFieldWithOutDocumentBuilder.Run();
+ //InsertASKFieldWithOutDocumentBuilder.Run();
+ InsertAuthorField.Run();
//// Images
//// =====================================================
diff --git a/Examples/Data/Programming-Documents/Fields/InsertNestedFields_out_.docx b/Examples/Data/Programming-Documents/Fields/InsertNestedFields_out_.docx
deleted file mode 100644
index 20c4a009f..000000000
Binary files a/Examples/Data/Programming-Documents/Fields/InsertNestedFields_out_.docx and /dev/null differ
diff --git a/Examples/Data/Programming-Documents/Fields/TestFile_out_.doc b/Examples/Data/Programming-Documents/Fields/TestFile_out_.doc
deleted file mode 100644
index abbdf7ee3..000000000
Binary files a/Examples/Data/Programming-Documents/Fields/TestFile_out_.doc and /dev/null differ
diff --git a/Examples/Data/Programming-Documents/Fields/in.doc b/Examples/Data/Programming-Documents/Fields/in.doc
new file mode 100644
index 000000000..8fb3b40fc
Binary files /dev/null and b/Examples/Data/Programming-Documents/Fields/in.doc differ
diff --git a/Examples/VisualBasic/Programming-Documents/Fields/InsertASKFieldWithOutDocumentBuilder.vb b/Examples/VisualBasic/Programming-Documents/Fields/InsertASKFieldWithOutDocumentBuilder.vb
new file mode 100644
index 000000000..bc80e6291
--- /dev/null
+++ b/Examples/VisualBasic/Programming-Documents/Fields/InsertASKFieldWithOutDocumentBuilder.vb
@@ -0,0 +1,41 @@
+Imports Microsoft.VisualBasic
+Imports System.IO
+Imports Aspose.Words
+Imports Aspose.Words.Fields
+Public Class InsertASKFieldWithOutDocumentBuilder
+ Public Shared Sub Run()
+ ' ExStart:InsertASKFieldWithOutDocumentBuilder
+ ' The path to the documents directory.
+ Dim dataDir As String = RunExamples.GetDataDir_WorkingWithFields()
+ Dim doc As New Document(dataDir & Convert.ToString("in.doc"))
+ ' Get paragraph you want to append this Ask field to
+ Dim para As Paragraph = DirectCast(doc.GetChildNodes(NodeType.Paragraph, True)(1), Paragraph)
+
+ ' We want to insert an Ask field like this:
+ ' { ASK \"Test 1\" Test2 \\d Test3 \\o }
+
+ ' Create instance of FieldAsk class and lets build the above field code
+ Dim field As FieldAsk = DirectCast(para.AppendField(FieldType.FieldAsk, False), FieldAsk)
+
+ ' { ASK \"Test 1\" " }
+ field.BookmarkName = "Test 1"
+
+ ' { ASK \"Test 1\" Test2 }
+ field.PromptText = "Test2"
+
+ ' { ASK \"Test 1\" Test2 \\d Test3 }
+ field.DefaultResponse = "Test3"
+
+ ' { ASK \"Test 1\" Test2 \\d Test3 \\o }
+ field.PromptOnceOnMailMerge = True
+
+ ' Finally update this Ask field
+ field.Update()
+
+ dataDir = dataDir & Convert.ToString("InsertASKFieldWithOutDocumentBuilder_out_.doc")
+ doc.Save(dataDir)
+
+ ' ExEnd:InsertASKFieldWithOutDocumentBuilder
+ Console.WriteLine(Convert.ToString(vbLf & "ASK field without using document builder inserted successfully." & vbLf & "File saved at ") & dataDir)
+ End Sub
+End Class
diff --git a/Examples/VisualBasic/Programming-Documents/Fields/InsertAdvanceFieldWithOutDocumentBuilder.vb b/Examples/VisualBasic/Programming-Documents/Fields/InsertAdvanceFieldWithOutDocumentBuilder.vb
new file mode 100644
index 000000000..568c296d7
--- /dev/null
+++ b/Examples/VisualBasic/Programming-Documents/Fields/InsertAdvanceFieldWithOutDocumentBuilder.vb
@@ -0,0 +1,48 @@
+Imports Microsoft.VisualBasic
+Imports System.IO
+Imports Aspose.Words
+Imports Aspose.Words.Fields
+Public Class InsertAdvanceFieldWithOutDocumentBuilder
+ Public Shared Sub Run()
+ ' ExStart:InsertAdvanceFieldWithOutDocumentBuilder
+ ' The path to the documents directory.
+ Dim dataDir As String = RunExamples.GetDataDir_WorkingWithFields()
+ Dim doc As New Document(dataDir & Convert.ToString("in.doc"))
+ ' Get paragraph you want to append this Advance field to
+ Dim para As Paragraph = DirectCast(doc.GetChildNodes(NodeType.Paragraph, True)(1), Paragraph)
+
+ ' We want to insert an Advance field like this:
+ ' { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 \\x 100 \\y 100 }
+
+ ' Create instance of FieldAdvance class and lets build the above field code
+ Dim field As FieldAdvance = DirectCast(para.AppendField(FieldType.FieldAdvance, False), FieldAdvance)
+
+
+ ' { ADVANCE \\d 10 " }
+ field.DownOffset = "10"
+
+ ' { ADVANCE \\d 10 \\l 10 }
+ field.LeftOffset = "10"
+
+ ' { ADVANCE \\d 10 \\l 10 \\r -3.3 }
+ field.RightOffset = "-3.3"
+
+ ' { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 }
+ field.UpOffset = "0"
+
+ ' { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 \\x 100 }
+ field.HorizontalPosition = "100"
+
+ ' { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 \\x 100 \\y 100 }
+ field.VerticalPosition = "100"
+
+ ' Finally update this Advance field
+ field.Update()
+
+ dataDir = dataDir & Convert.ToString("InsertAdvanceFieldWithOutDocumentBuilder_out_.doc")
+ doc.Save(dataDir)
+
+ ' ExEnd:InsertAdvanceFieldWithOutDocumentBuilder
+ Console.WriteLine(Convert.ToString(vbLf & "Advance field without using document builder inserted successfully." & vbLf & "File saved at ") & dataDir)
+ End Sub
+End Class
diff --git a/Examples/VisualBasic/Programming-Documents/Fields/InsertAuthorField.vb b/Examples/VisualBasic/Programming-Documents/Fields/InsertAuthorField.vb
new file mode 100644
index 000000000..db97ff49a
--- /dev/null
+++ b/Examples/VisualBasic/Programming-Documents/Fields/InsertAuthorField.vb
@@ -0,0 +1,31 @@
+Imports Microsoft.VisualBasic
+Imports System.IO
+Imports Aspose.Words
+Imports Aspose.Words.Fields
+Public Class InsertAuthorField
+ Public Shared Sub Run()
+ ' ExStart:InsertAuthorField
+ ' The path to the documents directory.
+ Dim dataDir As String = RunExamples.GetDataDir_WorkingWithFields()
+ Dim doc As New Document(dataDir & Convert.ToString("in.doc"))
+ ' Get paragraph you want to append this AUTHOR field to
+ Dim para As Paragraph = DirectCast(doc.GetChildNodes(NodeType.Paragraph, True)(1), Paragraph)
+
+ ' We want to insert an AUTHOR field like this:
+ ' { AUTHOR Test1 }
+
+ ' Create instance of FieldAuthor class and lets build the above field code
+ Dim field As FieldAuthor = DirectCast(para.AppendField(FieldType.FieldAuthor, False), FieldAuthor)
+
+ ' { AUTHOR Test1 }
+ field.AuthorName = "Test1"
+
+ ' Finally update this AUTHOR field
+ field.Update()
+
+ dataDir = dataDir & Convert.ToString("InsertAuthorField_out_.doc")
+ doc.Save(dataDir)
+ ' ExEnd:InsertAuthorField
+ Console.WriteLine(Convert.ToString(vbLf & "Author field without document builder inserted successfully." & vbLf & "File saved at ") & dataDir)
+ End Sub
+End Class
diff --git a/Examples/VisualBasic/Programming-Documents/Fields/InsertMailMergeAddressBlockFieldUsingDOM.vb b/Examples/VisualBasic/Programming-Documents/Fields/InsertMailMergeAddressBlockFieldUsingDOM.vb
new file mode 100644
index 000000000..ca448788f
--- /dev/null
+++ b/Examples/VisualBasic/Programming-Documents/Fields/InsertMailMergeAddressBlockFieldUsingDOM.vb
@@ -0,0 +1,50 @@
+Imports Microsoft.VisualBasic
+Imports System.IO
+Imports Aspose.Words
+Imports Aspose.Words.Fields
+Public Class InsertMailMergeAddressBlockFieldUsingDOM
+ Public Shared Sub Run()
+ ' ExStart:InsertMailMergeAddressBlockFieldUsingDOM
+ ' The path to the documents directory.
+ Dim dataDir As String = RunExamples.GetDataDir_WorkingWithFields()
+ Dim doc As New Document(dataDir & Convert.ToString("in.doc"))
+ Dim builder As New DocumentBuilder(doc)
+
+ ' Get paragraph you want to append this merge field to
+ Dim para As Paragraph = DirectCast(doc.GetChildNodes(NodeType.Paragraph, True)(1), Paragraph)
+
+ ' Move cursor to this paragraph
+ builder.MoveTo(para)
+
+ ' We want to insert a mail merge address block like this:
+ ' { ADDRESSBLOCK \\c 1 \\d \\e Test2 \\f Test3 \\l \"Test 4\" }
+
+ ' Create instance of FieldAddressBlock class and lets build the above field code
+ Dim field As FieldAddressBlock = DirectCast(builder.InsertField(FieldType.FieldAddressBlock, False), FieldAddressBlock)
+
+ ' { ADDRESSBLOCK \\c 1" }
+ field.IncludeCountryOrRegionName = "1"
+
+ ' { ADDRESSBLOCK \\c 1 \\d" }
+ field.FormatAddressOnCountryOrRegion = True
+
+ ' { ADDRESSBLOCK \\c 1 \\d \\e Test2 }
+ field.ExcludedCountryOrRegionName = "Test2"
+
+ ' { ADDRESSBLOCK \\c 1 \\d \\e Test2 \\f Test3 }
+ field.NameAndAddressFormat = "Test3"
+
+ ' { ADDRESSBLOCK \\c 1 \\d \\e Test2 \\f Test3 \\l \"Test 4\" }
+ field.LanguageId = "Test 4"
+
+ ' Finally update this merge field
+ field.Update()
+
+ dataDir = dataDir & Convert.ToString("InsertMailMergeAddressBlockFieldUsingDOM_out_.doc")
+ doc.Save(dataDir)
+
+ ' ExEnd:InsertMailMergeAddressBlockFieldUsingDOM
+ Console.WriteLine(Convert.ToString(vbLf & "Mail Merge address block field using DOM inserted successfully." & vbLf & "File saved at ") & dataDir)
+ End Sub
+
+End Class
diff --git a/Examples/VisualBasic/Programming-Documents/Fields/InsertMergeFieldUsingDOM.vb b/Examples/VisualBasic/Programming-Documents/Fields/InsertMergeFieldUsingDOM.vb
new file mode 100644
index 000000000..9d686a471
--- /dev/null
+++ b/Examples/VisualBasic/Programming-Documents/Fields/InsertMergeFieldUsingDOM.vb
@@ -0,0 +1,48 @@
+Imports Microsoft.VisualBasic
+Imports System.IO
+Imports Aspose.Words
+Imports Aspose.Words.Fields
+Public Class InsertMergeFieldUsingDOM
+ Public Shared Sub Run()
+ ' ExStart:InsertMergeFieldUsingDOM
+ ' The path to the documents directory.
+ Dim dataDir As String = RunExamples.GetDataDir_WorkingWithFields()
+ Dim doc As New Document(dataDir & Convert.ToString("in.doc"))
+ Dim builder As New DocumentBuilder(doc)
+
+ ' Get paragraph you want to append this merge field to
+ Dim para As Paragraph = DirectCast(doc.GetChildNodes(NodeType.Paragraph, True)(1), Paragraph)
+
+ ' Move cursor to this paragraph
+ builder.MoveTo(para)
+
+ ' We want to insert a merge field like this:
+ ' { " MERGEFIELD Test1 \\b Test2 \\f Test3 \\m \\v" }
+
+ ' Create instance of FieldMergeField class and lets build the above field code
+ Dim field As FieldMergeField = DirectCast(builder.InsertField(FieldType.FieldMergeField, False), FieldMergeField)
+
+ ' { " MERGEFIELD Test1" }
+ field.FieldName = "Test1"
+
+ ' { " MERGEFIELD Test1 \\b Test2" }
+ field.TextBefore = "Test2"
+
+ ' { " MERGEFIELD Test1 \\b Test2 \\f Test3 }
+ field.TextAfter = "Test3"
+
+ ' { " MERGEFIELD Test1 \\b Test2 \\f Test3 \\m" }
+ field.IsMapped = True
+
+ ' { " MERGEFIELD Test1 \\b Test2 \\f Test3 \\m \\v" }
+ field.IsVerticalFormatting = True
+
+ ' Finally update this merge field
+ field.Update()
+
+ dataDir = dataDir & Convert.ToString("InsertMergeFieldUsingDOM_out_.doc")
+ doc.Save(dataDir)
+ ' ExEnd:InsertMergeFieldUsingDOM
+ Console.WriteLine(Convert.ToString(vbLf & "Merge field using DOM inserted successfully." & vbLf & "File saved at ") & dataDir)
+ End Sub
+End Class
diff --git a/Examples/VisualBasic/RunExamples.vb b/Examples/VisualBasic/RunExamples.vb
index 7f11b8984..62000d337 100644
--- a/Examples/VisualBasic/RunExamples.vb
+++ b/Examples/VisualBasic/RunExamples.vb
@@ -111,6 +111,11 @@ Module RunExamples
'ChangeLocale.Run()
'UpdateDocFields.Run()
'InsertField.Run()
+ 'InsertMergeFieldUsingDOM.Run();
+ 'InsertMailMergeAddressBlockFieldUsingDOM.Run()
+ 'InsertAdvanceFieldWithOutDocumentBuilder.Run()
+ 'InsertASKFieldWithOutDocumentBuilder.Run()
+ InsertAuthorField.Run()
'' Images
'' =====================================================
diff --git a/Examples/VisualBasic/VisualBasic.vbproj b/Examples/VisualBasic/VisualBasic.vbproj
index 178fd49ac..bdc79911b 100644
--- a/Examples/VisualBasic/VisualBasic.vbproj
+++ b/Examples/VisualBasic/VisualBasic.vbproj
@@ -131,7 +131,12 @@
+
+
+
+
+