How To open 1 WORD instance with several documents
Problem description (mail from the userlist):
<snip>
I am using word with OLE and everything is ok, i can open the file, print ...
My problem is, that everytime I open a worddocument, another word instance is created and the user get's two wordicons in the taskbar.
This is because i define my variable V-WordApplication (OLE) with the instantiation = automatic
How can i check if word is allready open and how can i get the handler?
If i have the handler i can refer to the object by ComHandleSet (variable, handle) or create a new instance.
</snip>
Solution:
Record Main:
Select Virt O-MS Word Global (OLE) ("A") Type: Microsoft Word, Object name: Global, Automatic
Select Virt O-MS Word Application (OLE) ("B") Type: Microsoft Word, Object name: Application, None
Select Virt v-MS Word ObjectHandle ("C") Num 10
Select Virt v-COM Error ("D") Num N10
Record Suffix:
Remark "Check for Open WORD-session"
Update C Expr: COMHandleGet (A)
Block Cnd: (C=0)
Remark "Create New WORD Instance"
Update D Expr: COMObjCreate ('B'VAR)
Block Else
Remark "Append to the existing Application"
Update D Expr: COMHandleSet ('B'VAR, C)
End Block
...and then you have to set it visible, open documents and activate it, etc....
Regards
Frank Van Herreweghe
Frank.van.herreweghe@telenet.be
Category
CategoryHowTo
There are no comments on this page. [Add comment]