Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Automation
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Word Automation
Miscellaneous
Thread ID:
00573436
Message ID:
00573436
Views:
48
I am trying to run the sample code from the Technical Article "Microsoft Visual Foxpro and Advanced Com".

I have edited out the Outlook and Excel information, as at this time I am only interested in Word.

Here is what I have:

PUBLIC ow as word.application
oWordEvents = NEWOBJECT("WordEvents")
ow = NEWOBJECT("word.application")
oWordEvents.ow = ow
?"Word",EVENTHANDLER(ow,oWordEvents)
ow.visible = .t.
ow.Activate
ow.Documents.Add

_screen.WindowState= 1

DEFINE CLASS WordEvents as Custom
implements applicationevents2 in "word.application"
ow = .null.
PROCEDURE applicationevents2_startup()
?PROGRAM()
PROCEDURE applicationevents2_quit
?PROGRAM()
procedure applicationevents2_DocumentBeforeClose(Cancel,Doc)
?PROGRAM()
procedure DocumentBeforeClose(Cancel,Doc)
?PROGRAM()
procedure applicationevents2_DocumentBeforePrint(Cancel,Doc)
?PROGRAM()
procedure applicationevents2_DocumentBeforeSave(Doc,SaveAsUI,Cancel)
?PROGRAM()
procedure applicationevents2_DocumentChange
?PROGRAM()
procedure applicationevents2_DocumentOpen(Doc)
?PROGRAM()
procedure applicationevents2_NewDocument(Doc)
?PROGRAM()
procedure applicationevents2_WindowActivate(Doc,Wn)
?PROGRAM()
procedure applicationevents2_WindowBeforeDoubleClick(Sel,Cancel)
?PROGRAM()
procedure applicationevents2_WindowBeforeRightClick(Sel,Cancel)
?PROGRAM()
procedure applicationevents2_WindowDeactivate(Doc,Wn)
?PROGRAM()
procedure applicationevents2_WindowSelectionChange(Sel)
?PROGRAM(),sel.text
IF sel.start < sel.end
sel.InsertAfter("Fox!")
*!* mtmp = sel.text
*!* sel.text=STRTRAN(mtmp,"good","Great!")
endif
PROCEDURE destroy
?PROGRAM()
IF !ISNULL(this.ow)
?EVENTHANDLER(this.ow,this,.t.)
ENDIF
ENDDEFINE

When I run this code I get "Type library word.application not found" when it tries to create th oWordEvents object. I want to be able to return the name the user saved the document as so that I can attach it to a record in my application.

Any help would be greatly appreciated.
Jim Oswell
Practice Masters, Inc.
Fox Forever
The wake never pushes the boat.
Next
Reply
Map
View

Click here to load this message in the networking platform