Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi all,

    We recently added this code to all of our correspondence templates so that our users couldn't access our disclaimer text:

    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, _
    			   wdPrimaryFooterStory, wdPrimaryHeaderStory
    		ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    		Exit Sub
    	Case Else
    	End Select
    
    End Sub
    The presence of this code seems to affect format painter in that using it in double-click "mode" no longer works. Can anyone enlighten as to why this might be occurring? This isn't the first problem the "protection" code has caused for us but we've managed to work around the others.

    As always, thanks in advance!

    Violet

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Using the WindowSelectionChange event has some undesirable side effects, such as turning off Extend Mode (invoked by pressing F8) and the Format Painter. There is no workaround for this, as far as I know, so I fear you'll have to decide what is more important for you: disabling access to the header and footer, or using the Format Painter...

  3. #3
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi Hans,

    I suspected that would be the case. Personally, I feel that the protection has caused three issues already and who knows how many in future, so if it were up to me, I wouldn't use it anymore...that's not to say everyone will agree however!

    Thanks very much, have a good day!

    V

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •