Document Data (Placeholders):
{FirstName} {MiddleName} {LastName}
If a middle name is available it replaces data correctly
If it is not available, I tried ^r^r to remove the word {MiddleName} and 01 space so it will only show first & last names with a single space between.
But ^r^r replaces only {MiddleName} and does not remove extra space created after removing {MiddleName} placeholder.
I am trying to replace excel data with an MS word placeholder and it fails if the middle name is unavailable. I have to update many other fields in the same document hence used for loop with a list of all placeholders.
What does the datatable you’re reading from look like? You could consider replacing “{FirstName} {MiddleName} {LastName}” with string.join(currentdatarow.ItemArray, " ") instead of replacing each of the names separately.
For each field, there will be a separate column in the datatable and as mentioned earlier there are other several fields in the same datatable for ease of implementation I have used for-loop.
I don’t want to disturb the current framework and want to know if there is any other way to achieve it.
Do you think that you could show me a text sample and a sample of the row from the data table? I’m sure that it’s possible to do this with a sequence of replace statements, but without more details, I’m having trouble imagining what they might be.