Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2005

Tip: Looking for answers? Try searching our database.

Headers & Footers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dan Bridgland - 26 Jul 2005 12:50 GMT
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
Dan Bridgland - 05 Aug 2005 10:37 GMT
I am still in desperate need of help on this one,

Please, someone, Help

Dan

> Hi all,
>
[quoted text clipped - 60 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.