gibbo1715
11-01-2005, 01:55 PM
I am trying to have some code check if various parts of my document are protected or not using the code below, I then want to unprotect the document and add to a bbokmark before re protecting the parts that were protected again
My code always returns my first section is true (Protected) and the rest it returns nothing at all, can anyone tell me what im doing wrong here please
cheers
gibbo
Dim Section1 As String
Dim Section2 As String
Dim Section3 As String
Dim Section4 As String
If ActiveDocument.Sections(1).ProtectedForForms = True Then
Section1 = "True"
Else
Section1 = "False"
End If
If ActiveDocument.Sections(2).ProtectedForForms = True Then
Section1 = "True"
Else
Section1 = "False"
End If
If ActiveDocument.Sections(3).ProtectedForForms = True Then
Section1 = "True"
Else
Section1 = "False"
End If
If ActiveDocument.Sections(4).ProtectedForForms = True Then
Section1 = "True"
Else
Section1 = "False"
End If
On Error Resume Next
ActiveDocument.Unprotect Password:="test"
ActiveDocument.Bookmarks("Log").Range.Text = CreateObject("WScript.Network").UserName _
& " Opened the application at " _
& Format(Now, "hh:mm dd/mm/yy") & vbNewLine
ActiveDocument.Sections(1).ProtectedForForms = Section1
ActiveDocument.Sections(2).ProtectedForForms = Section2
ActiveDocument.Sections(3).ProtectedForForms = Section3
ActiveDocument.Sections(4).ProtectedForForms = Section4
ActiveDocument.Protect Password:="test", NoReset:=False, Type:= _
wdAllowOnlyFormFields
My code always returns my first section is true (Protected) and the rest it returns nothing at all, can anyone tell me what im doing wrong here please
cheers
gibbo
Dim Section1 As String
Dim Section2 As String
Dim Section3 As String
Dim Section4 As String
If ActiveDocument.Sections(1).ProtectedForForms = True Then
Section1 = "True"
Else
Section1 = "False"
End If
If ActiveDocument.Sections(2).ProtectedForForms = True Then
Section1 = "True"
Else
Section1 = "False"
End If
If ActiveDocument.Sections(3).ProtectedForForms = True Then
Section1 = "True"
Else
Section1 = "False"
End If
If ActiveDocument.Sections(4).ProtectedForForms = True Then
Section1 = "True"
Else
Section1 = "False"
End If
On Error Resume Next
ActiveDocument.Unprotect Password:="test"
ActiveDocument.Bookmarks("Log").Range.Text = CreateObject("WScript.Network").UserName _
& " Opened the application at " _
& Format(Now, "hh:mm dd/mm/yy") & vbNewLine
ActiveDocument.Sections(1).ProtectedForForms = Section1
ActiveDocument.Sections(2).ProtectedForForms = Section2
ActiveDocument.Sections(3).ProtectedForForms = Section3
ActiveDocument.Sections(4).ProtectedForForms = Section4
ActiveDocument.Protect Password:="test", NoReset:=False, Type:= _
wdAllowOnlyFormFields