We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Replace in word document

Thread ID:

Created:

Updated:

Platform:

Replies:

121378 Dec 2,2015 09:55 AM Dec 8,2015 01:55 AM Windows Forms 1
loading
Tags: DocIO
Øyvind Knappskog Olsen
Asked On December 2, 2015 09:55 AM

Hi
I have a wordfile that I want to replace a text in. I use the following code:
WordDocumentrebarTemplate=newWordDocument();
rebarTemplate.Open(textBox1.Text,FormatType.Automatic);
 
rebarTemplate.Replace("%1%_P:RebarChecked","newvalue",false,true);
 
Directory.CreateDirectory(@"C:\temp\synctest\");
rebarTemplate.Save(@"C:\temp\synctest\syncreplace.docx");
 
rebarTemplate.Close();
I get the argumentoutofrangeexception 'startIndex cannot be larger than length of string.' when the replace line is called.
I get this exception from the original file.
However, if I open the word file in word 2013 and alter one or more of the texts and save it, the code runs ok.
The original word file open correctly in word 2013.
Any idea what may be wrong?
See the attached file...

Regards
Øyvind Knappskog Olsen
Norconsult Informasjonssystemer AS

Attachment: RebarTemplateNOR_bc140b34.zip

Sarathkumar V [Syncfusion]
Replied On December 8, 2015 01:55 AM

Hi Øyvind Knappskog Olsen,

Sorry for the delay being caused.

We could see that you have created incident for the below query under your account. Please follow up with that incident for further updates.

Please let us know if you have any queries.

Regards,
Sarath


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;