Heading numbers not updating properly

I created a simple Word 2003 file with several page references, updated the fields and page layout in Aspose.Words, and looked at the resulting document. The heading numbers don’t appear to be updated correctly if the \r or \n switches are used. Instead of seeing the heading number, I see the heading name. The \w switch does appear to be working correctly. Are there known limitations about using the \r or \n switches in references in Aspose.Words? If there are known limitations, is it possible to get a list of switches which don’t currently work so I’ll only try using those switches which do work?

Hello

Thank you for reporting this problem to us. 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. I’m afraid currently there is no list of supported switches. Please, feel free to write up more about your requirements and we will see if we can add supporting needed switches.
Best regards,

Hi Mark,
This issue is still unresolved, however there is work around code you can use for now which will hopefully help out.
The code is attached to this post, you can use it like below. It is to be called after any call to UpdateFields.

Document doc = new Document("Testing.docx");
// Update REF fields with the proper values.
UpdateRefFields(doc);
doc.Save("Testing Out.docx");

Thanks,

This code does not seem to solve the problem. I had to convert it to VB.Net, since I’m using VB.Net rather than C#. I’m attaching my code, so can check to make sure I converted it correctly. Please send VB.Net code fragments in the future if possible, because my employer uses VB.Net, nor C#.
The Replace at the end of UpdateRefFields tried to replace “1.1” with “1.1”, and “1.2” with “1.2”, so it did not do anything in the end. I think you wanted it to replace “1.1” with “2.1” and “1.2” with “2.2”.
There were several small problems in the code that was attached that I tried to correct.

  1. There is a call to GetFieldResult, which is not defined. On the other hand GetFieldValue is defined, but is never called. I changed the name of GetFieldValue to be GetFieldResult.
  2. TrimEnd needs to take an array of Chars as an argument, not a single Char.
  3. There is code to compare para.ListFormat.List and bookmarkPara.ListFormat.List for equality. There is no = operator for Aspose.Words.Lists.List. I used Object.ReferenceEquals to test for equality.
  4. The word “calculated” was misspelled as “calulated”.

Not a bug, but a difference between VB and C#: I defined listCodes to be of type Char(), not String(). The elements were defined to be ChrW(0), ChrW(1), etc. I think this should still work. I could have kept the String() type, and defined the elements to be ChrW(0).ToString, ChrW(1).ToString, etc.
See my attached file AsposeFixes.txt for my VB code.
Thanks,
Mark Novick
senior software engineer
ASC

Hi Mark,
Thanks for this additional information.
If you need sample code translated to VB.NET in the future please ask us, we will glady provide it for you.
I have attached the VB.NET code for the above method. It works properly on my side. You can use the code like below.

Dim doc As Document = New Document("referenceBug.doc")
doc.UpdateFields()
UpdateRefFields(doc)
doc.Save("referenceBug Out.doc")

You are correct GetFieldValue should be GetFieldResult, it was just a typo.
In C# you can provide the TrimEnd method with each character as a parameter, this is just the difference between the two languages.
If you have any further queries, please feel free to ask.
Thanks,

Thanks for providing the VB.NET code sample. Unfortunately the code sample still does not work correctly. I still get the same text as I had before. My code calls UpdateFields on the entire document and then calls your UpdateRefFields method.
Here is the modified version of the document that my co-worker provided. It seems to solve the problem. Maybe you can see what is the essential difference between this version and the problematic version in order to fix the problem in Aspose.Words.
Thanks,
Mark Novick
senior software engineer
ASC

Hello,
Thank you for additional information.
I took the code from the previous post (which Adam attached).
Picked up your document “referenceBug.doc”. And unfortunately, I could not reproduce your problem. My output document exactly the same as input. ie workaround is working properly. Please check back again.

The issues you have found earlier (filed as WORDSNET-3788) have been fixed in this .NET update and in this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.