Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Aug 31, 2023 3:47 am

Hi team,

I'm using the spire.doc version 11.8.18 and .Net 6.0
When I replace text in the StructureDocumentTagInline, an error occured:
Object reference not set to an instance of an object.
at Spire.Doc.Documents.TextSelection.get_SelectedText()
at Spire.Doc.Documents.TextSelection.GetAsOneRange(Boolean IsCopyFormat)
at Spire.Doc.Documents.TextSelection.GetAsRange(Boolean isCopyFormat)
at Spire.Doc.Document.Replace(Regex pattern, String replace)
at Program.<Main>$(String[] args) in E:\Duyen\src\ConsoleApp1\ConsoleApp1\Program.cs:line 13

I'm having a lot of customer complaints about this error. Please let us know the results soon.
Thank you
Code: Select all
using Spire.Doc;
using System.Text.RegularExpressions;

Console.WriteLine("Hello, World!");

Document document = new Document();
document.LoadFromFile(@"E:\error3.docx");
var matchString = "@@JobNumber@@";
var value = "new value";

// Error when replace with regex
var result1 = document.Replace(new Regex(matchString), value);

// Error when replace string
var result2 = document.Replace(matchString, value, true, true);

document.SaveToFile(@"E:\" + Guid.NewGuid().ToString("N") + ".docx");

duyennguyen
 
Posts: 3
Joined: Thu Aug 31, 2023 3:23 am

Thu Aug 31, 2023 6:00 am

Hi,

Thank you for your feedback.

Upon examining the document you provided, I attempted to open it using Microsoft Word. Unfortunately, I encountered difficulties, and the document failed to open properly. Please refer to the attached screenshot for reference.
test.png

Based on this observation, it appears that there is an issue with the source document itself, which is causing our product to be unable to parse and process it correctly. As a result, the error you experienced when attempting to replace the content using regular expressions and strings is likely stemming from the problematic nature of the document.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Thu Aug 31, 2023 6:08 am

Thank you for the reply.
Please try again with the file I attached.

Thanks

duyennguyen
 
Posts: 3
Joined: Thu Aug 31, 2023 3:23 am

Thu Aug 31, 2023 6:27 am

Hi,

The same issue occurs when opening the document you newly attached with MS Word. Please provide us with a correct document so that we can reproduce your issue. Thank you for your assistance.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Thu Aug 31, 2023 6:39 am

Hi Triste,
Thank you for your patient,
Please try again with the attachment file.
My coworker and I are able to open it with both Microsoft Word and WPS Office.

Thank you very much.

duyennguyen
 
Posts: 3
Joined: Thu Aug 31, 2023 3:23 am

Thu Aug 31, 2023 7:21 am

Hi,

Thanks for your feedback.
According to your feedback, I attempted to open the document you provided using both Microsoft Word and WPS Office, the document opened without any difficulties in WPS Office. Additionally, my colleague also successfully opened it using both Microsoft Word and WPS Office. This suggests that the problem may be specific to my installation of Microsoft Word, rather than an inherent issue with the document itself. I sincerely apologize for the inconvenience caused.

I have been able to reproduce the issue on my end. I have recorded it in our issue tracking system with the ticket number SPIREDOC-9836. For your situation, I have given your two issues the highest priority. Once two issues are fixed, I will inform you asap.

Once again, I apologize for any inconvenience this may have caused. If you have any additional questions or require further assistance, please do not hesitate to reach out to us.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Fri Sep 22, 2023 7:10 am

Hi,

Thanks for your patience.
Glad to inform you that we just released Spire.Doc 11.9.19 hotfix, which has fixed your issue SPIREDOC-9836 and SPIREDOC-9834, please download from the following link and have a test.
Website: https://www.e-iceblue.com/Download/download-word-for-net-now.html

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.Doc