How to copy document using automation?

Hi

I have been using the following code to select the whole SWriter document from Visual FoxPro. However, if the document contains a table the code only selects the 1st cell in the table. How do I change my code so that it selects the whole document even if the document contains tables etc.? The reason for selecting the whole document is for type of mail merge where I insert a new page as an exact copy of the original document and merge the data. I repeat this process for each record in the table.

loDsp=.oMergeSrvMgr.createInstance("com.sun.star.frame.DispatchHelper")
Dimen laArgs(1)
laArgs(1)=.oMergeSrvMgr.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
loDsp.executeDispatch(.oMergeDoc.getCurrentController().getFrame(), ".uno:SelectAll", "", 0, @laArgs)
.oMergeText = .oMergeDoc.getCurrentController().getTransferable()

Thanks,
Simon

Heh, but native Mail Merge feature already has this mode built in - it’s Save Merged DocumentsSave as single large document.

Yes that is true but we have other reasons for using this method.

See Andrew Pitonyak’s OpenOffice.org Macros Explained V3, Listing 249 (sect. 11.3, p.267).