On Error Function not Working

A

Amit

I tried to run the following code but it is not working:

Sub Amit()
Set myDoc = ActiveDocument

On Error GoTo ErrHandler:

If myDoc.ProtectionType = wdAllowOnlyComments Then
myDoc.Unprotect Password:="abcd"
myDoc.Password = "abc d"
myDoc.Protect Type:=wdAllowOnlyComments, Password:="abc d"
Exit Sub
Else: myDoc.Protect Type:=wdAllowOnlyComments, Password:="abcd"
Exit Sub
End If

ErrHandler:
MsgBox "An error occurred: " & CStr(Err.Number) & vbCrLf & _
"Description: " & Err.Description

End Sub


Please Smbody HELP!!!
 
T

Tony Jollans

It works for me. Could you be a bit more specific about what the error is.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top