Open and Manage Multiple Word Docs
Posted on 2006-05-18
I would like to be able to open and manage multiple word docs from my Delphi app (myApp) in the following manner
a) assume myApp knows the names of the docs, and displays them eg in a listview
b) when the user clicks on a doc, it gets opened in Word (and I would like it not to be opened if it is already opened ie to avoid the message "do you want to revert to the saved document")
c) the newly opened word instance (window) gets positioned at a place and of a size under the control of myApp .. effectively I want a "cascading" appearance
d) the user can close any of the docs opened from myApp from myApp
e) if the user closes myApp, and there are Word instances running which were opened by myApp, then they get closed.
ShellExecute could be used to open the docs, but the returned handle won't help. Somehow I will need to find a process ID (or something?) for the most recently opened instance so that can get stored in myApp. And for the window positioning and sizing, I need to do what?
I thought about using TOleContainer and had a look at the two delphi demos .. MDI means that all the documents are contained within the MyApp mainform and share a single menu (where are the Word toolbars?), and this is not the sort of user experience I want. Basically I want myApp to act as the "controller" or "launch pad" for a number of docs .. with something more than just a dumb launch. (ie resizing, positioning, only launching if not open etc etc)
Ideas, suggestions, and code would be welcome.