I am writing my first InDesign script and I am having trouble with a seemingly simple task.
I have selected a PageItem from from one of my open Documents, I am trying to copy it so that I can paste it into another of my open documents.
When I try to copy the Selection I get the following error message:-
"Cannot copy/cut due to invalid selection state."
I can see that the Document from which I am copying has a valid selection: SecondDoc.Selection.Count = 1 and that the correct PageItem has been selected.
I can see that the InDesign application does not have a valid selection: InDesignApp.Selection.Count=0, so when I execute InDesignApp.Copy method I get the above error message.
How do I copy the document selection to the application selection?
The following does not seem to work: InDesignApp.Selection=SecondDoc.Selection.
Here is the failing code sample
InDesignApp.Selection = SecondDoc.Selection ????????????????????????
Any help with this very simple question would be appreciated !
I have discovered the answer to this.
For a selection to be added to the Application.Selection property, the document and the page from which the selection is made must be the ActiveDocument and ActivePage respectively.
Otherwise the selection is added to the Document.Selection property.