Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Has anyone got the code below to work? If you have, please could you
give me a detailed steps into getting it to work http://word.mvps.org/faqs/customization/ ProtectWord2000PlusHeader.htm How can I prevent users from editing the header of a document in Word 2000 or higher? Article contributed by Bill Coan 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. For Word 97, click here 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, _ wdPrimaryFooterStory, wdPrimaryHeaderStory ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument Exit Sub Case Else End Select End Sub |
#2
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Hi Robert,
The code works for me (Word 2003). I just pasted it into the ThisDocument module and saved my doc as a Word template (.dot). There are three things I can think of that I believe would stop it from working: 1. Pasting the code somewhere other than the template's ThisDocument module. 2. Saving the "template" as a .doc and renaming it to be a .dot. 3. Having your macro security level set to High and having the template located in an un-trusted location. If none of the above apply in your case, post back and someone may be able to suggest something else. Also, let us know what happens when you try to use the template - nothing or an error of some sort. Regards. Ed " wrote: Has anyone got the code below to work? If you have, please could you give me a detailed steps into getting it to work http://word.mvps.org/faqs/customization/ ProtectWord2000PlusHeader.htm How can I prevent users from editing the header of a document in Word 2000 or higher? Article contributed by Bill Coan 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. For Word 97, click here 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, _ wdPrimaryFooterStory, wdPrimaryHeaderStory ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument Exit Sub Case Else End Select End Sub |
#3
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Hi again,
One correction - after I pasted the code I removed the "---------" lines. Cheers. Ed "Ed" wrote: Hi Robert, The code works for me (Word 2003). I just pasted it into the ThisDocument module and saved my doc as a Word template (.dot). There are three things I can think of that I believe would stop it from working: 1. Pasting the code somewhere other than the template's ThisDocument module. 2. Saving the "template" as a .doc and renaming it to be a .dot. 3. Having your macro security level set to High and having the template located in an un-trusted location. If none of the above apply in your case, post back and someone may be able to suggest something else. Also, let us know what happens when you try to use the template - nothing or an error of some sort. Regards. Ed " wrote: Has anyone got the code below to work? If you have, please could you give me a detailed steps into getting it to work http://word.mvps.org/faqs/customization/ ProtectWord2000PlusHeader.htm How can I prevent users from editing the header of a document in Word 2000 or higher? Article contributed by Bill Coan 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. For Word 97, click here 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, _ wdPrimaryFooterStory, wdPrimaryHeaderStory ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument Exit Sub Case Else End Select End Sub |
#4
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Ultimately this will not *prevent* users from editing the header. It will
only *inhibit* them momentarily. No document you allow a user to see is immune from interference. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Ed wrote: Hi again, One correction - after I pasted the code I removed the "---------" lines. Cheers. Ed "Ed" wrote: Hi Robert, The code works for me (Word 2003). I just pasted it into the ThisDocument module and saved my doc as a Word template (.dot). There are three things I can think of that I believe would stop it from working: 1. Pasting the code somewhere other than the template's ThisDocument module. 2. Saving the "template" as a .doc and renaming it to be a .dot. 3. Having your macro security level set to High and having the template located in an un-trusted location. If none of the above apply in your case, post back and someone may be able to suggest something else. Also, let us know what happens when you try to use the template - nothing or an error of some sort. Regards. Ed " wrote: Has anyone got the code below to work? If you have, please could you give me a detailed steps into getting it to work http://word.mvps.org/faqs/customization/ ProtectWord2000PlusHeader.htm How can I prevent users from editing the header of a document in Word 2000 or higher? Article contributed by Bill Coan 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. For Word 97, click here 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, _ wdPrimaryFooterStory, wdPrimaryHeaderStory ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument Exit Sub Case Else End Select End Sub |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Multiple users editing the same Word Document | Microsoft Word Help | |||
Word 2003 - VB Code Does not work like it did in Word 2000 | Mailmerge | |||
Prevent users from Printing a Word 2003 Document | Microsoft Word Help | |||
how to prevent users from adding more pages to the document in MS. | Microsoft Word Help | |||
document locked for editing word 2000 | Microsoft Word Help |