Lock specific pages for viewing in WORD 2007

Dexter666

New Member
Joined
May 28, 2009
Messages
31
Is there a way to lock specific pages in a word document from vieweing? F.i. I have a 20 pages document and the first 15 pages would be "viewable" for every user who opens it, but when he enters the 16th page a password would be needed to view the rest of the document.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Insert into your document where the locked text will start:
1 text box named txtPassword : 1 command button named cmdSubmit
insert a bookmark named 'ReadOn'
Select everything after the bookmark, edit Font and check the Hidden attribute.

Apply this code to the VBA
' In the document Code
Code:
Private Sub cmdSubmit_Click()
    If txtPassword.Value = "password" Then ' [Set your password]           
        txtPassword.Value = ""
        Call EnableContent
    Else
        txtPassword.Value = ""
        MsgBox "Incorrect Password", vbOKOnly, "Oops"
    End If
End Sub
Sub EnableContent()
    Selection.EndKey Unit:=wdLine
    Selection.EndKey Unit:=wdStory, Extend:=wdExtend
 
    With Selection.Font
        .Hidden = False
    End With
 
    Selection.GoTo What:=wdGoToBookmark, Name:="ReadOn"
End Sub

Prepping for distribution:
With the IDE, Project Properties Protection, lock the IDE with a password.
When you are ready to publish the document, mark it as Final via Prepare.
This will lock the user-editing; but will still allow the VBA to edit.
 
Upvote 0

Forum statistics

Threads
1,225,516
Messages
6,185,438
Members
453,289
Latest member
ALPOINT_AIG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top