I would like to be able to protect/prevent the header from beeing opened. This I have asked many people and got a VBA code from someone, but it did not work in all cases.
Using protection on section 1 for instance is not acceptable. Then some functions in Word is disabled. There should be possible to detect the event when a header is accessed and then e.g. starting a dialog box in which one shall type the info to be placed in the header.
The code I got, but which does not work properly is as follows:
The following code, pasted into the This Document module of a Word 2000 Template, will keep users out of the header and footer of documents based on that template:
Option Explicit
‘reserve memory for an application variable
Private WithEvents wdApp As Word.Application
Private Sub Document_Close()
‘release the memory for the application variable
Set wdApp = Nothing
End Sub
Private Sub Document_New()
‘assign Word to the application variable
If wdApp Is Nothing Then
Set wdApp = ThisDocument.Application
End If
End Sub
Private Sub Document_Open()
‘assign Word to the application variable
If wdApp Is Nothing Then
Set wdApp = ThisDocument.Application
End If
End Sub
Private Sub wdApp_WindowSelectionChange(ByVal Sel As Selection)
‘quit if active doc isn’t attached to this template
If ActiveDocument.AttachedTemplate ThisDocument Then Exit Sub
‘get out of the header/footer if we’re in it
If Sel.StoryType = wdEvenPagesFooterStory Or _
Sel.StoryType = wdEvenPagesHeaderStory Or _
Sel.StoryType = wdFirstPageFooterStory Or _
Sel.StoryType = wdFirstPageHeaderStory Or _
Sel.StoryType = wdPrimaryFooterStory Or _
Sel.StoryType = wdPrimaryHeaderStory Then
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Exit Sub
End If
End Sub
Hope this is understandable and that somebody can give me some advise.
Berst regards
Bj