This project has moved and is read-only. For the latest updates, please go here.

Document.FindAll and DocX.InsertTable out of range exception

Jan 11, 2014 at 1:26 AM
Edited Jan 11, 2014 at 1:29 AM
I am trying to replace some text with a table, but am having some trouble.
The FindAll function returns a single occurrence of the string I am looking for, yet when I attempt to call document.InsertTable(index, tbl), I get an "Specified argument was out of the range of valid values" that traces back to the HelperFunctions.GetFirstParagraphEffectedByInsert(DocX document, Int32 index) function.

Calling just document.InsertTable(tbl) works, but puts the table at the end of the document.

I have tried what was suggested in this (slightly old) thread with no success.

The document is simply:

Here is the data:

and the search term is "{Table_Here}"

Any suggestions as to what could be going wrong?
Jan 21, 2014 at 7:58 AM
I am having the same issue.
I need to replace text with Paragraph with multiple formattings.
Any update on this?
Mar 3, 2014 at 8:07 PM

Same here.

May 20, 2014 at 9:50 AM
InsertTable used DocX.paragraphLookup dictionary for search apropriate paragraph. But that Dictionary not populate...
I'am (for self) modify DocX.cs, function PostLoad, before
return document;
insert that:
            foreach (var paragraph in document.Paragraphs)
                if (!document.paragraphLookup.ContainsKey(paragraph.endIndex))
                    document.paragraphLookup.Add(paragraph.endIndex, paragraph);
Marked as answer by MadBoy on 6/3/2014 at 4:14 AM
Jun 3, 2014 at 12:14 PM
Added this to main source code. Please verify if it works. Thanks monstress