Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OLE Word Doc Read Only behavior

Status
Not open for further replies.

Statey603

Programmer
Nov 10, 2009
196
US
I have an OLE Word Doc object in a screen. The document data comes from a BLOB in the database [not an actual Word Doc file].
The ole object is configured to open using ole_obj.Activate(Offline!) as opposed to ole_obj.ConnectToNewObject("word.application").

I am trying to achieve WRITE PROTECTED behavior when the BLOB is displayed in the Word Doc that launches on Activate.

I am calling Protect as follows:
ole_obj.object.application.ActiveDocument.Protect(wdAllowOnlyFormFields, FALSE, 'P@ssWord')
and also tried
ole_obj.object.application.ActiveDocument.Protect(0, TRUE, "*****" )

The BLOB data gets displayed in Word, however, the user is allowed to modify the text in the document and click save and close.
NOTE: The changes are NOT saved, which achieves my desired end result, but, the user would have no idea the document is in WRITE PROTECTED mode.

I was hoping that either the user would be prompted when trying to Save indicating read only or maybe presenting the Word Doc grayed out.
It just seems to me that somebody else must have attempted this type of behavior, but I guess we are limited to the PB Ole Word functionality.
Hopefully I have overlooked something.

I am hoping that someone might have examples on how to achieve Word Doc Write Protection that is a bit more obvious to the user.
[PowerBuilder 12.5]


Thanks
 
I've got some additional information on this one.

The Word Doc editing behavior that I described of no obvious Write Protection on the document appears to only apply when opening BLOB data via an OLE Word Doc with a Word Template that is a Form. When I used just a basic Word Document, I was NOT allowed to type in the document so the Write Protection was obvious.

I think this has to do with the Protect call using enumerated type: wdAllowOnlyFormFields
[ole_obj.object.application.ActiveDocument.Protect(wdAllowOnlyFormFields, FALSE, 'P@ssWord')]

This specific situation that I am working on requires a Word Template with a Form/Table so I am not sure if there is a way around it.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top