Hi Brian, thanks so much for your help. In our simple test file we were doing this solution worked, however observing your code I checked the following logic:
- Code: Select all
TextSelection[] selections = document.FindAllString(listParamWord[0].ToString(), true, true);
All code:
- Code: Select all
foreach (Paragraph newParagraph in paragraphs)
{
TextSelection[] selections = document.FindAllString(listParamWord[0].ToString(), true, true);
if (selections != null)
{
if (t == -1 || i == -1 || y == -1)
{
ownerParagraph = selections[0].GetAsOneRange().OwnerParagraph;
int index = body.ChildObjects.IndexOf(ownerParagraph);
body.ChildObjects.Insert(index, newParagraph);
}
else
{
ownerParagraph = selections[0].GetAsOneRange().OwnerParagraph;
int index = body.Tables[t].Rows[i].Cells[y].ChildObjects.IndexOf(ownerParagraph);
body.Tables[t].Rows[i].Cells[y].ChildObjects.Insert(index, newParagraph);
}
}
}
if (t == -1 || i == -1 || y == -1)
{
body.ChildObjects.Remove(ownerParagraph);
}
else
{
body.Tables[t].Rows[i].Cells[y].ChildObjects.Remove(ownerParagraph);
}
But we have several pages and several variables, not always the first variable that comes from the file will be this list treatment, it can be just a simple replace.
I've uploaded a part of our structure with a few more variables that we use. In addition to the option doors that will also have this control to replace Doors.1.height and etc.
I tried to change the code to get the first parameter of the list to replace when executed and it worked, but when it goes to execute other options such as doors, faucets and other items that may have dimensions, it gets lost. We have the following pattern, all {{variables}} within the braces {{}} are simple and straightforward replacements, but the {{variables.*.text}} that contain * between dots are lists that can have multiple lines 1, 2,3,4,5,6... How would this logic look?
Attached, the list of parameters and the word, thanks again.
Login to view the files attached to this post.