XingTemplateTags.vb
C# VB
'''' This code is part of Document Solutions for Word demos.'' Copyright (c) MESCIUS inc. All rights reserved.''Imports System.IOImports GrapeCity.Documents.Word
'' This sample demonstrates the DsWord Data/Report Templates API,'' which allows developers to retrieve all template tags from a document,'' along with details such as tag text, associated data element (if any),'' and the tag's location within the document.'''' In this sample, we retrieve all tags and replace each with a sequence of 'x' characters.'''' See also: MarkTagsInPDF for an example of using this API in PDF export scenarios.Public Class XingTemplateTags Function CreateDocx() As GcWordDocument Dim doc = New GcWordDocument() doc.Load(Path.Combine("Resources", "WordDocs", "House_Rental_Template.docx")) '' Fetch information about all data template tags in the document: Dim tagInfos = doc.DataTemplate.GetTemplateTagInfos() '' Replace all tags with sequences of 'X' character: For Each tagInfo As GrapeCity.Documents.Word.Templates.TemplateTagInfo In tagInfos Dim tagText = tagInfo.Text tagInfo.Range.Replace(tagText, New String("x"c, tagText.Length)) Next Return doc End FunctionEnd Class