We're using Word 2010 and have a PowerShell script that reads a table in a Word docx file and use it to populate the autocorrect dictionary. It works for the regular entries that don't require formatting; but it breaks on the items that need to use the AddRichText method. It gives this error:

And the code for the PowerShell is as follows; it reads from a 3 column table in the Word doc and uses them to populate the autocorrect. The first column has the Name, the next has the Value, and the last can be an X to indicate if it's rich text (has formatting).

1 Answer
1

The code looks correct and unfortunately the exception details are ambiguous and no help. The only thing I can think of that might be wrong is that AddRichText might not like being passed a cell range instead of paragraph range which is what it expects. Try changing that and see if it helps.