.vbs: write protection for header/footer in Word

Viewed 97

I am currently working on some visual basic scripts (.vbs) for word. I need to find out whether the header/footer is write protected or not. I used following snippet:

Sub main(testAction)

Dim doc 'As Word.Document
Dim paAction 'As Engine.clsParamAction
Dim sAction 'As String
Dim paDocument 'As Engine.clsParamAction
Dim sDocumentName 'As String
Dim paValue 'As Engine.clsParamAction

Set paDocument = testAction.paramAction("Document Name", True)
If paDocument Is Nothing Then
    sDocumentName = "#1"
else
    sDocumentName = paDocument.inputView.Value
End If
Set doc = WaitForDocument(sDocumentName , lTimeout)

Set paAction = testAction.paramAction("Action", True)   
sAction = paAction.inputView.value

Set paValue = testAction.paramAction("Value", True)  
select case (lcase(sAction))
    case "headersectionisprotected":
        paValue.actValue = doc.Sections(1).Headers(2).Range.Sections.Item(1).ProtectedForForms
        paValue.HandleActValue
        Exit Sub    
end select
End Sub

The subroutine is called via Tricentis Tosca - I am sorry I am not able to give a reproducible "standalone" example:

Subroutine integrated to Tricentis Tosca

Obviously the command "doc.Sections(1).Headers(2).Range.Sections.Item(1).ProtectedForForms" does not work as expected - the return value is always true, no matter if the header is protected or not. Note: Tosca is not making the troubles here because I have several other subs integrated like that and all of them are working fine.

0 Answers
Related