Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problems intercepting Word Events
Message
De
18/05/2009 08:24:35
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Titre:
Problems intercepting Word Events
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01400371
Message ID:
01400371
Vues:
92
I have been successfully intercepting Word events in versions of Word pre 2007 using the implements mechanism:
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".

The string (Word.Application) cannot be replaced by any mechanism I am aware of (eg variable, macro substitution etc), but has to be printed out in full in inverted commas. Eg I want to use something like this:
m.OlbPath = "Z:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE12\MSWORD.OLB"
DEFINE CLASS WordEvents as Custom
IMPLEMENTS ApplicationEvents2 IN m.OlbPath
This 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.)

Incidentally the Word.Application look up does work for creating an automatable instance of Word:
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.

Has anyone come up with a solution to this one?

Dominic
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform