Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

OLE Word Doc Read Only behavior

OLE Word Doc Read Only behavior

OLE Word Doc Read Only behavior

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]


RE: OLE Word Doc Read Only behavior

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close