We help IT Professionals succeed at work.

Read only object in Web Browser control

ihtzaz
ihtzaz asked
on
Medium Priority
1,294 Views
Last Modified: 2008-03-03
I am using a Web Browser control in a VB application. When a word document is shown in the browser control, one can edit the document.  I want to control that i.e. I would like some of my users to just view the document and some to edit.  How do I set the read-only kind of property.
Comment
Watch Question

IT Operations
CERTIFIED EXPERT
Commented:
maybe something like this:


Option Explicit
Dim bEnableEdit As Boolean
Private Sub Form_Load()
WB1.Navigate "C:\temp\Attachs\hadas.doc"
End Sub

Private Sub WB1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is WB1.Object) Then
    If Right$(WB1.LocationURL, 3) = "doc" Then
        Dim oTarget As Word.Document
        Set oTarget = WB1.Document
        If bEnableEdit = True Then
            oTarget.Unprotect Password:="pwd"
        Else
            oTarget.Protect Password:="pwd"
        End If
       
    End If
End If
End Sub
Richie_SimonettiIT Operations
CERTIFIED EXPERT

Commented:
oops!

Option Explicit
Dim bEnableEdit As Boolean

Private Sub Form_Load()
WB1.Navigate "C:\temp\Attachs\hadas.doc"
bEnableEdit = False
End Sub

Private Sub WB1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is WB1.Object) Then
    If Right$(WB1.LocationURL, 3) = "doc" Then
        Dim oTarget As Word.Document
        Set oTarget = WB1.Document
        If bEnableEdit = False Then
            oTarget.Protect Type:=wdAllowOnlyComments, Password:="pwd"
        End If
       
    End If
End If
End Sub
Richie_SimonettiIT Operations
CERTIFIED EXPERT

Commented:
Any progress?
CERTIFIED EXPERT
Author of the Year 2009

Commented:
Hi ihtzaz,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept Richie_Simonetti's comment(s) as an answer.

ihtzaz, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
Per recommendation, force-accepted.

Netminder
CS Moderator