Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with Word method
Message
From
12/05/2001 00:30:54
 
 
To
11/05/2001 19:29:11
Peter Wagner
Point Informática Ltda.
Limeira, Brazil
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00506528
Message ID:
00506583
Views:
12
Hi Peter,

Your problem is that you are trying to fire off Protect from a Range object, and it scopes to a Document. Get an object reference to the document. The easiest way would be to change your Documents.Add line to "oDoc=oWordApplication.Documents.Add("Normal.dot",.F.)". Then you can "oDoc.Protect" later on.


>I have a problem, I dont know how to execute a Word method form VFP
>At the sample below I want to protect the document, but it allways returns an
>error when I call the method Protect, it returns a OLE error: unknown name
>Word2000/VFP6.0 + SP5
>
>Could someone help me please
>TIA
>
>
>oWordApplication = CREATEOBJECT("Word.Application")
>oWordApplication.VISIBLE = .F.
>oWordApplication.Documents.ADD("normal.dot", .F.)
>
>* Select the document
>oSelection = oWordApplication.ActiveWindow.ActivePane.SELECTION
>oSelection.TypeText ("Test to protect this document.")
>
>* Select Range ( all text form the document )
>oSelection2 = oWordApplication.ActiveWindow.ActivePane.SELECTION.range
>
>IF oWordApplication.ActiveDocument.ProtectionType = wdNoProtection && no protection
> WITH oSelection2
> .PROTECT
> .TYPE = wdAllowOnlyFormFields
> .PASSWORD = "free"
> ENDWITH
>ENDIF
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform