Headers & Footers

D

Dan Bridgland

Hi all,

I am following instructions and using code from
http://word.mvps.org/FAQs/Customization/ProtectWord2000PlusHeader.htm

I am using Word 2003.

The only change I have made is to remove the "wdPrimaryFooterStory,
wdPrimaryHeaderStory"line as I only want this to work on the first page
header & footer only.

The problem I have is when I create a new document form the template
and try to amend the header or footer I receive a error message "Object
Variable or With block variable not set Error (91)"

then Im prompted to debug and the debug refers to the line
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

if I ignore the error, close the new document and again create a new
document from the template, I do not receive the error message and the
header & footer on only the first page is protected, as required

Why does the error message occour and why does it work the second time
you create a document from the template? Why? Why? Why!

SOMEONE PLEASE HELP ME, IM GOING CRAZY.

Thanks in advance.

Dan

the code>

Option Explicit
'reserve memory for an application variable
Private WithEvents wdApp As Word.Application

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
Select Case Sel.StoryType
Case wdEvenPagesFooterStory, wdEvenPagesHeaderStory, _
wdFirstPageFooterStory, wdFirstPageHeaderStory
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Exit Sub
Case Else
End Select

End Sub
 
D

Dan Bridgland

I am still in desperate need of help on this one,

Please, someone, Help

Dan
 

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