public void RenameMergeFields()
        {
            // Specify your document name here.
            Aspose.Words.Document doc = new Aspose.Words.Document(ExDir + "RenameMergeFields.doc");

            // Select all field start nodes so we can find the merge fields.
            NodeCollection fieldStarts = doc.GetChildNodes(NodeType.FieldStart, true);
            foreach (FieldStart fieldStart in fieldStarts)
            {
                if (fieldStart.FieldType.Equals(FieldType.FieldMergeField))
                {
                    MergeField mergeField = new MergeField(fieldStart);
                    mergeField.Name = mergeField.Name + "_Renamed";
                }
            }

            doc.Save(ExDir + "RenameMergeFields Out.doc");
        }
Exemplo n.º 2
0
        [Test] //ExSkip
        public void RenameMergeFields()
        {
            // Specify your document name here.
            Aspose.Words.Document doc = new Aspose.Words.Document(MyDir + "RenameMergeFields.doc");

            // Select all field start nodes so we can find the merge fields.
            NodeCollection fieldStarts = doc.GetChildNodes(NodeType.FieldStart, true);

            foreach (FieldStart fieldStart in fieldStarts)
            {
                if (fieldStart.FieldType.Equals(FieldType.FieldMergeField))
                {
                    MergeField mergeField = new MergeField(fieldStart);
                    mergeField.Name = mergeField.Name + "_Renamed";
                }
            }

            doc.Save(MyDir + "RenameMergeFields Out.doc");
        }