Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Allow user to modify a Word document?
Message
From
18/01/2009 07:35:09
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01372571
Message ID:
01374754
Views:
68
I did cut and paste in all of the the additional procedures, but what I missed was that one "slight" change at the top :-)

The only reason that my class was defined as custom instead of session was because it was data driven and it needed to "see" the data in the form.

Workstations should run Word 2000 or greater but I don't even know how many versions that encompasses--or where to get the type libraries for versions I don't own. Any suggestions?

Here is how you can check for the version. Getting the type libraries for versions you don't own - well, I don't know about that one. However, You may be in luck here. I am pretty sure that the interface defined for ApplicationEvents2 is the same in Word 2K - Word 2003, so you can use the same handler class for all of those versions if this is indeed the case. The only time you need a different handler class is when the interface changes - I ran into this a few years ago when I was automating Excel for a client and my code broke when he installed Excel 2003 on one of his machines - MS had changed the interface between XP and 2003!
LPARAMETERS tcApplication
LOCAL llOK, loApp, lcHandler, loErr, lcMsg
llOK = .T.
TRY 
  Thisform.oApp = CREATEOBJECT( tcApplication + [.Application] )
CATCH
  TEXT TO lcMsg TEXTMERGE NOSHOW PRETEXT 3
    It seems that <<tcApplication>> is not installed on the computer.
    You must have <<tcApplication>> installed to run this process.
  ENDTEXT
  MESSAGEBOX( lcMsg, 64, Major WAAAAAHHHHH!] )
  llOK = .F.
ENDTRY
IF llOK  
  ***********************************************************************
  *** Changed By.: Marcia G. Akins on 14 January 2006
  *** Reason.....: Now see if we have 2K, XP, 2003, or 2007
  ***********************************************************************
  IF INLIST( ALLTRIM( Thisform.oApp.version ), [9.0], [10.0], [11.0], [12.0] )
    *** sonstruct the name of the handler to use
    lcHandler = tcApplication + [Handler] + ICASE( [9.0], [2K], [10.0], [XP], [11.0], [2003], [12.0], [2007] ) + [.prg] )
    TRY
       loHandler = NEWOBJECT( tcApplication + [Handler], lcHandler )
       CATCH TO loErr
         IF loErr.ErrorNo = 1  && File does not exist
           TEXT TO lcMsg TEXTMERGE NOSHOW PRETEXT 3
             The System is unable to find <<lcHandler>>.
              Please select <<lcHandler>> in the open file dialog
              when it appears.
              
              Sorry for the inconvenience...
           ENDTEXT
           MESSAGEBOX( lcMsg, 64, [Major WAAAHHHHH!] )
           lcHandler = GETFILE( [prg], [Automation Handler], [Select], 0, [Find Handler] )
           IF NOT EMPTY( lcHandler )
             Thisform.oHandler = NEWOBJECT( tcApplication + [Handler], lcHandler )
           ELSE
             llOK = .F.
           ENDIF
         ELSE  && loErr.ErrorNo = 1  && File does not exist
           TEXT TO lcMsg TEXTMERGE NOSHOW PRETEXT 3
             The following error occurred when trying to
             instantiate the automation handler from <<lcHandler>>:

             <<loErr.Message>>
           ENDTEXT
           MESSAGEBOX( lcMsg, 64, [Major WAAAHHHHH!] )
           llOK = .F.
         ENDIF  && loErr.ErrorNo = 1  && File does not exist
       ENDTRY
  ELSE  && INLIST( ALLTRIM( loApp.version ), [9.0], [10.0], [11.0], [12.0] )
    TEXT TO lcMsg TEXTMERGE NOSHOW PRETEXT 3
      You must have at least version either 2000 of  <<tcApplication>> installed to run this process.
    ENDTEXT
    MESSAGEBOX( lcMsg, 64, [Major WAAAHHHH!] )
    llOK = .F.   
    Thisform.oApp.quit()
  ENDIF  && INLIST( ALLTRIM( loApp.version ), [9.0], [10.0], [11.0], [12.0] )
ENDIF

RETURN llOK
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform