We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Call to update fields in Word document modifies hyperlink to another document

Using VB.NET 2003, .NET Framework 1.1 with Aspose.Words.dll version 9.1.0.0:
We have a module in our product that handles document version control. In this module, when we are opening a copy of the document for editing with an Aspose.Words object, we add custom properties to hold and display document version control info. We also add a watermark containing only block ‘DRAFT’ to denote this as an edited version not yet approved.
After making these changes, the following two lines are used to update any field values and save the changes:

CType(app, Aspose.Words.Document).UpdateFields()
CType(app, Aspose.Words.Document).Save(*[file path string]*)

The ‘update fields’ line in modifying a simple hyperlink to another document file to a hyperlink to the current directory of the edited document. If I step over that line of code the hyperlink is unaffected. Sample document attached.
Thanks in advance,
John Romanchik, Software Application Developer - Cebos, Ltd.
Brighton, MI USA

Please remember I am using VB.NET 2003, .NET Framework 1.1.

While your support staff has been very responsive, two recent fixes sent were compiled to .NET Framework 2.0 - and caused delays of a day or two in receiving the proper dll file.

Thanks
again,

John Romanchik, Software Application Developer - Cebos, Ltd.
Brighton, MI USA

Hello

Thanks for your request. I cannot reproduce the reported problem on my side using the latest version of Aspose.Words (9.3.0). You can download this version from here:
https://releases.aspose.com/words/net
I use the following code for testing:

Dim doc As Document = New Document("yourDoc.doc")
doc.UpdateFields()
doc.UpdatePageLayout()
doc.Save("out.doc")

Could you please try using the latest version and let me know how it goes on your side?
Also if you try UpdateFields inside your document using MS Words, you will get the same result as Aspose.Words produces.
But, I have found other problem. By some reason a hyperlink name appears inside TOC. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed.
Best regards,

Attached is the resulting document after using Aspose.Words.dll version 9.3.0.0 and adding the line of code to update page layout prior to saving.

Hi
Thanks for your request. When you call the Document.UpdateFields method, Aspose.Words updates (entirely rebuilds) the TOC field, but does not insert page numbers into the TOC field yet. Aspose.Words calculates correct page numbers and inserts into the TOC when the document layout is built e.g. when you save to PDF or print. So to update page numbers in TOC, you should call Document.UpdatePageLayout or just save document in PDF or XPS.

doc.UpdateFields();
doc.UpdatePageLayout();
doc.Save("out.doc");

Regarding the problem with HYPERLINK name inside TOC, you will be notified as soon as it is fixed.
Best regards,

Please give me an update on this. Reading through the response from yesterday, I am not sure you have the real problem here. The real problem is that the running the ‘update fields’ code below, with or without the second line to update layout, radically expands (adding many new items) and alters the table of contents as originally configured (please see ‘before’ and ‘after’ documents previously attached).

doc.UpdateFields();
doc.UpdatePageLayout();

This is not what happens when you update the fields in MS Word.

Also, I was expected a support incident number sent to me.

Thanks in advance,
John Romanchik, Software Application Developer - Cebos, Ltd.
Brighton, MI USA

Hello

Thank you for additional information. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed.
Best regards,

Is there a support issue # for it?
Thank You,
John Romanchik, Software Application Developer - Cebos, Ltd.
Brighton, MI

Hello
Thanks for your request. The issue number is 19691.
Best regards,

I have not heard anything in some time on this. Can I get an estimate when I will receive a fix for this issue?

Thank You,
John Romanchik, Software Application Developer - Cebos, Ltd.
5936 Ford Court, Ste. 203

Brighton, MI 48116
(810) 534-2222 x240
(810) 534-0131 fax

E-mail: john.romanchik@cebos.com

Hello

Thanks for your inquiry. Currently I cannot provide you any reliable estimate regarding this issue. You will be notified as soon as it is resolved.
Best regards,

A few observations/questions:

  1. –I am disappointed to hear you cannot give an estimate when this issue will be fixed.
  2. –We have been using Aspose.Cells and Aspose.Words for a little over a year now and several postings reporting bugs have all been corrected by a ‘hot fix’ which was usually received in a week or less. Why is that not forthcoming in this issue?
  3. –What are my options to request an escalation/expedited resolution for my issue?

Thank You and eagerly anticipating your response,
John Romanchik, Software Application Developer - Cebos, Ltd.
5936 Ford Court, Ste. 203

Brighton, MI 48116
(810) 534-2222 x240
(810) 534-0131 fax

E-mail: john.romanchik@cebos.com

Hello

Thanks for your inquiry. I added your request to my monthly report, so its priority will be increased. I will notify you as soon as the problem is resolved. Sorry for inconvenience.
Best regards,

Hi John,
Thanks for your inquiry.
You can look into escalating your issues by purchasing the priority support package. This package will ensure your issue will be looked at with precedence.
Also, could you please clarify why you need to update the TOCs through UpdateFields/UpdatePageLayout. From your original description, it is not clear why as it does not appear you are editing the content which would change the TOC in any way.
Thanks,

We are creating custom document properties that whose values contain control info (rev. dates, levels) and other metadata about the document from the database. When the change is approved in our software, we move the file from a draft to official location, and call the update fields command to refresh the display of document fields that reference those custom document properties.

Hi John,
Thanks for this additional information.
If you are not looking to update the TOCs in your document then you may be able to avoid these issues by only updating non TOC fields. Please see the code below which achieves this. This method should be called in place of UpdateFields and UpdatePageLayout.

Public Shared Sub UpdateNonTOCFields(ByVal doc As Document)
' Iterate through every paragraph in the document.
For Each para As Paragraph In doc.GetChildNodes(NodeType.Paragraph, True)
Dim fieldStarts As NodeCollection = para.GetChildNodes(NodeType.FieldStart, True)
' Current range contains at least one field.
If fieldStarts.Count > 0 Then
Dim updateFields As Boolean = True
For Each start As FieldStart In fieldStarts
' Skip updating this range if it contains a TOC.
If start.FieldType Is FieldType.FieldTOC Then
updateFields = False
End If
Next start
' Update the fields in the current range.
If updateFields Then
para.Range.UpdateFields()
End If
End If
Next para
End Sub

Currently the code will not update fields that are split over more than one paragraph. If this is an issue it can be fixed.
Thanks,

Looks like it should work for what we are trying to do. I will try this code first part of next week at the latest. Just one small clarification - the document object in function parameter, am I correct in assuming that this is a Aspose.Words document object?
**Thanks for your quick response, **
John Romanchik, Software Application Developer - Cebos, Ltd.
5936 Ford Court, Ste. 203

Brighton, MI 48116
(810) 534-2222 x240
(810) 534-0131 fax

E-mail: john.romanchik@cebos.com

Hi John,
Yes, that is correct.
Thanks,

When I place the code in my application (VB.NET, Framework 1.1) running Aspose.Words 9.3.0.0:

For Each start As FieldStart In fieldStarts

The line above returns a ‘FieldStart not defined’ error.

I played around with the code a little, and while Intellisense finds ‘NodeType.FieldStart’ when creating the node collection just above this line, but O never could get from a node in node collection of the node type ‘FieldStart’ to a ‘FieldStart’ object.

Hi

Thanks for your inquiry. You should just add:
Imports Aspose.Words.Fields
Please see the following link:
https://reference.aspose.com/words/net/aspose.words.fields/fieldstart/
Best regards,