DEFINE CLASS WordEvents as Custom IMPLEMENTS ApplicationEvents2 IN "Word.Application"My understanding is that VFP looks in the registry for "Word.Application" and maps this to the relevent olb file. This does not work in Word 2007, and you appear to have to replace the text "Word.Application" with the exact path of the OLB file. Eg. "Z:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE12\MSWORD.OLB".
m.OlbPath = "Z:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE12\MSWORD.OLB" DEFINE CLASS WordEvents as Custom IMPLEMENTS ApplicationEvents2 IN m.OlbPathThis not working is obviously a real pain as it is both Word version and machine specific. In fact, the only way I have been able to get this to work is by dynamically creating a series of program files with different strings pointing to various possible OLB paths, compile them and then run them. (I even tried using a SHELLEXECUTE to create the Class definition, but this didn't work as VFP released the class the moment the SHELLEXECUTE completed.)
oWord = CREATEOBJECT("Word.Application")My aim is to find a solution that is portable between machines and Word versions, entirely contained in an executable, and that does not involve permanently installing any add-ins to Word.