First off, give up going the native route. There’s no way that I’ve found that you can convert an array to an
InDesign.Objects object. Also, subclassing
DoScript method of the
Below is an extension method of the
InDesign.Document object that takes two or more
Id‘s. I haven’t found a way to cast specific objects (
InDesign.TextFrame, etc) to generic
InDesign.PageItem so instead of writing tons of method signatures I’m just passing their internal integer IDs. The code is in VB.Net and should be pretty self-explanatory so someone should be able to convert it to C# very easily. Yes, I know the newlines aren’t necessary, but I like them. Why an Extension method? This snippet is one of many in my library and I find them easier to use if they’re extensions instead of sitting in a helper class.
To call this Extension method, assuming that you have an
InDesign.Document object called
TF and a
Just to help people that are searching, one of the error messages that this will help resolve is:
Unable to cast object of type 'System.Object' to type 'InDesign.Objects'.