Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BINDEVENT to MSWord?
Message
From
29/08/2003 11:26:59
 
 
To
29/08/2003 08:29:43
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00824505
Message ID:
00824577
Views:
37
This message has been marked as a message which has helped to the initial question of the thread.
You can get the version of MS-Word with oWord.verion
you can then hook to the right class defining one for each version you want to support.
oWord = CREATEOBJECT("Word.application")
DO CASE
CASE oWord.Version = "8.0"
   oWordEvents=NEWOBJECT("WordEvents8")
CASE oWord.Version = "9.0"
   oWordEvents=NEWOBJECT("WordEvents9")
CASE oWord.Version = "10.0"
   oWordEvents=NEWOBJECT("WordEvents10")
...
ENDCASE

EVENTHANDLER(owrd,oWordEvents)
oWord.Documents.Add
oWord.visible = .t.
oWord.Activate
Good Luck

Yanick

>Hi Cetin,
>Thanks.
>One question though. Doesn't that a knowledge where word sits on the user's machine?
>Some users have it on c: some on d:, some are useing office 9 some office 10 I user office 2003?
>How would I handle that
>
>Peter
>
>
>>>Hi,
>>>I would like to use bindevent to let my VFP program know when the word doc it just opened for the user is closed so I can react to it
>>>
>>>Peter
>>
>>Peter,
>>Try eventhandler instead. ie:
>>
>>
>>oWordEvents=NEWOBJECT("WordEvents")
>>
>>local owrd as 'word.application'
>>oWrd = NewObject('word.application')
>>EVENTHANDLER(owrd,oWordEvents)
>>owrd.Documents.Add
>>owrd.visible = .t.
>>owrd.Activate
>>
>>
>>DEFINE CLASS WordEvents AS session OLEPUBLIC
>>	IMPLEMENTS ApplicationEvents2 IN ;
>>          "c:\program files\microsoft office\office\msword9.olb"
>>* ...
>>	PROCEDURE ApplicationEvents2_DocumentBeforeSave(Doc AS VARIANT, ;
>>             SaveAsUI AS LOGICAL, Cancel AS LOGICAL) AS VOID
>>* Your code here
>>	ENDPROC
>>
>>*...
>>Enddefine
>>
>>PS: To create 'WordEvents' code :
>>-Open object explorer
>>-Load Word type lib
>>-Expand events node
>>-Drag&drop ApplicationEvents2 node on to a code window
>>Cetin
Previous
Reply
Map
View

Click here to load this message in the networking platform