Free Support Forum - aspose.com

Losing formatting when replacing text

I have an xslt routine that places some text in a Word document. The text is "glossary_term_seqnum". The vertical alignment is set to superscript. All looks good after the document is created. See attachemnt called before.docx.





glossary_term_seqnum


Now, I want to change all the occurences of "glossary_term_seqnum" in the document to numeric sequence numbers. I use the following function that I found on the Aspose website to do this. All works fine except that I lose the formatting. The text is no longer displayed as superscript. See attachemnt called after.docx.

Currently I am using the trial version of the software where the temporary license has expired. My company has orderd the software and am currently waiting for the licensed version. Is it possible that the unlicensed version of the software might be causing this?

Please advise how I may keep this formatting.

Here is the excerpt of the code that I used.

Dim AsposeDoc As New clsAspose
Dim outputFile As String
outputFile="c:temp\before.docx"
AsposeDoc.OpenAsposeDocument(outputFile)
If InStr(AsposeDoc.Range.Text, "glossary_term_seqnum") > 0 Then
AsposeDoc.Range.Replace(New System.Text.RegularExpressions.Regex("glossary_term_seqnum"), New

clsAspose.MyReplaceEvaluator(), True)
AsposeDoc.Range.UpdateFields()
AsposeDoc.SaveDoc(outputFile)
End If

Attached is the clsAspose.txt which contains a portion of my vb class

before.docx which is the document that contains the text to be replaced with the correct formatting.

after.doc is the document that show the replaced text with the incorrect formatting.

Thank You!

Hi Howard,


Thanks for your inquiry. I have managed to reproduce the same issue at my side. This issue can be reproduced by using following code snippet.

<span style=“font-size:
10.0pt;font-family:“Courier New”;color:#2B91AF;mso-no-proof:yes”>Document<span style=“font-size:10.0pt;font-family:“Courier New”;mso-no-proof:yes”> doc = new Document(MyDir

  • “in.docx”);<o:p></o:p>

doc.Save(MyDir + "Out.docx");


I have logged this issue as WORDSNET-8064 in our issue tracking system. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

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


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