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

Free Support Forum - aspose.com

PageCount breaks range.replace

It appears that when you fetch the page count from a document, subsequent calls to range.replace no longer work. For example, in the code below none of the range.replace calls work AFTER the page count property is queried:

            aspDoc.Range.Replace("[Fax.PageCount]", aspdoc.pagecount.tostring, False, False)

            If strRecipientName <> vbNullString Then aspDoc.Range.Replace("[Fax.RecipientName]", strRecipientName, False, False)
            If strRecipientNumber <> vbNullString Then aspDoc.Range.Replace("[Fax.RecipientNumber]", strRecipientNumber, False, False)
            If strSubject <> vbNullString Then aspDoc.Range.Replace("[Fax.Subject]", strSubject, False, False)
            If strNote <> vbNullString Then aspDoc.Range.Replace("[Fax.Note]", strNote, False, False)
            If strDocumentName <> vbNullString Then aspDoc.Range.Replace("[Fax.DocumentName]", strDocumentName, False, False)

Everything after the first line of code above will execute but the range.replace function does not properly replace the tokens in the document. If I comment out the query to the page count, the remaining code will replace the tokens properly.


Thanks for your inquiry. We have tested the scenario with a sample document using Aspose.Words for .NET 17.10 and unable to notice the reported issue. If you are using some old version then please download and try latest version of Aspose.Words for .NET, it will resolve the issue. Furthermore please also use new replace method for the purpose. However, if the issue persists then please share your sample input document as ZIP file along with sample code(without compilation error) to replicate the issue at our end.