Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Desperately Seeking Main Document (Windows XP/Word XP)

    Hello All.

    Believe it or not the code below in my WindowSelectionChange application event prevented people from viewing the header area (by double clicking the header or footer in print layout view in Word 2000) and messing up my header information. My macro would instead show a form and the end-user could modify the header info in the form. Now that we are converting to Windows and Office XP it does not work anymore. I've tried to put similar code into the WindowBeforeDoubleClick application event but no luck. I've spent hours trying different things, but nothing works. Anyone have a suggestion?

    Private Sub objWord_WindowSelectionChange(ByVal Sel As Selection)
    If IsObjectValid(Sel) Then
    If Sel.Information(wdInHeaderFooter) = True Then
    ActiveDocument.ActiveWindow.View.SeekView = WdSeekMainDocument
    ShowHeaderInfoForm
    End If
    End If
    End Sub

    Kyle Knowles
    eSubmission Publisher
    Connetics Corporation
    Palo Alto, CA

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Desperately Seeking Main Document (Windows XP/Word XP)

    Works for me. Have you got all the pieces strung together and the event handler initialized? I find that after compiling, I sometimes have to initialize again. Users won't have this problem, unless they are recompiling your module. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  3. #3
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Desperately Seeking Main Document (Windows XP/Word XP)

    Actually, my WindowSelectionChange is not even triggered. My other application events do trigger (DocumentBeforeSave, DocumentChange, DocumentOpen). Now if i stick my procedure from WindowSelectionChange into WindowBeforeDoubleClick, it does trigger, but Sel.Information(wdInHeaderFooter) comes back false. I'm baffled.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Desperately Seeking Main Document (Windows XP/Word XP)

    No, that's right. "Before" double-click is before the user enters the header. I get this result:

    <pre>Fired WindowBeforeDoubleClick @ 760 55499.36 False
    Fired WindowSelectionChange @ 0 55499.39 True</pre>

    From these procedures:

    <pre>Private Sub objWord_WindowBeforeDoubleClick(ByVal Sel As Selection, Cancel As Boolean)
    Debug.Print "Fired WindowBeforeDoubleClick @ " & Sel.Start, Timer, _
    Sel.Information(wdInHeaderFooter)
    End Sub

    Private Sub objWord_WindowSelectionChange(ByVal Sel As Selection)
    If IsObjectValid(Sel) Then
    Debug.Print "Fired WindowSelectionChange @ " & Sel.Start, Timer, _
    Sel.Information(wdInHeaderFooter)
    If Sel.Information(wdInHeaderFooter) = True Then
    ActiveDocument.ActiveWindow.View.SeekView = wdSeekMainDocument
    MsgBox "Gotcha"
    End If
    End If
    End Sub</pre>

    Not sure why your results are different...

  5. #5
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Desperately Seeking Main Document (Windows XP/Word XP)

    Thank you. This helps.

    I belive my global template is the problem. I created it in Word 2000. When I exported my application events into a new XP template my WindowSelectionChange would finally trigger and work as it did in Word 2000. I am a newbie to VBA but I guess there is some degree of incompatability between the two versions for VBA or my template was corrupt?

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Desperately Seeking Main Document (Windows XP/Word XP)

    Corruption happens, 'though I notice it most with UserForm modules rather than class or code modules. Doing an Export/Import every several hours can avoid a number of bizarre problems. Also, an entirely clean template created for a specific version of Word probably is a good thing in itself.

Posting Permissions

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