I have to open a word docx do some modifications and save with a different name. The problem is that I have FILENAME field all over in the document and on save aspose cannot update this field.
Thanks for your inquiry. Aspose.Words does not know what will be the name of the output document, because you can specify any file name you like. So FILENAME field should be updated upon saving the document. We had already logged this feature as WORDSNET-2723 in our issue tracking system. We will update you via this forum thread once this feature is available.
You can use following code snippet as a workaround.
<span style=“font-family: “Courier New”; color: rgb(43, 145, 175);” lang=“EN-GB”>Document<span style=“font-family: “Courier New”;” lang=“EN-GB”> doc = new
Document(MyDir + “in.docx”);<o:p></o:p>
doc.Save(MyDir + "AsposeOut.docx");
public void SetFileName(string filename, Document _document)
foreach (FieldStart fieldStart in _document.GetChildNodes(NodeType.FieldStart, true))
Run filenameMergeformat = (Run)fieldStart.NextSibling; // Text=FILENAME \* MERGEFORMAT
FieldSeparator fieldSeparator = (FieldSeparator)filenameMergeformat.NextSibling; // Separator
Run filenameCurrentValue = (Run)fieldSeparator.NextSibling; // Run Text=
filenameCurrentValue.Text = filename;
Is there any news on this feature being implemented in the near future?
A post was split to a new topic: Update FILENAME upon saving the document