Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Library diff between XP and 2000 (Office XP, Word 2002 SP-2)

    in Word Templates I have checked the following Tools/References in VB for Word 2000, as follows:
    Visual Basic for Applications
    Microsoft Word 9.0 Object Librarary
    Microsoft Office 9.0 Object Librarary
    Microsoft Forms 2.0 Object Library
    OLE Automation

    In Office XP Object Libaries are called 10.0

    Are there any differences between the two?

    My problem:
    In my template I have an EventClassModule:

    Option Explicit

    Public WithEvents App As Word.Application

    Dim ProtectHandler As New EventClassModule

    Sub Register_Event_Handler()
    Set ProtectHandler.App = Word.Application
    End Sub

    Private Sub App_WindowSelectionChange(ByVal Sel As Selection)
    On Error Resume Next
    '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
    If Sel.StoryType = wdEvenPagesFooterStory Or _
    Sel.StoryType = wdEvenPagesHeaderStory Or _
    Sel.StoryType = wdFirstPageFooterStory Or _
    Sel.StoryType = wdFirstPageHeaderStory Or _
    Sel.StoryType = wdPrimaryFooterStory Or _
    Sel.StoryType = wdPrimaryHeaderStory Then
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    If ActiveDocument.ReadOnly = True Then
    Exit Sub
    End If

    frmLetterEn.Show
    Exit Sub
    End If
    End Sub

    In ThisDocument I have the following procedures:
    Option Explicit
    Public WithEvents App As Word.Application
    Dim ProtectHandler As New EventClassModule

    Sub Register_Event_Handler()
    Set ProtectHandler.App = Word.Application
    End Sub

    Private Sub Document_New()
    Register_Event_Handler
    frmLetterEn.Show
    End Sub

    and in a UserForm I have the same:
    Private WithEvents wdApp As Word.Application
    Dim ProtectHandler As New EventClassModule

    Sub Register_Event_Handler()
    Set ProtectHandler.App = Word.Application
    End Sub

    These procedures will result in the UserForm to open if someone are doubleclicking in the Header/Footer as long as I use Office 2000/Word 2000 SR-1.
    But this is not possible in XP. It looks as the SetProtectHandler is not acted upon.

    Can someone help me?

    Regards
    Bj

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

    Re: Library diff between XP and 2000 (Office XP, Word 2002 SP-2)

    Hi Bj

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Library diff between XP and 2000 (Office XP, Word 2002 SP-2)

    If Macro Security is set to high, try setting it to Medium.

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

    Re: Library diff between XP and 2000 (Office XP, Word 2002 SP-2)

    It is set to low.

  5. #5
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: Library diff between XP and 2000 (Office XP, Word 2002 SP-2)

    Hi Kyle,

    It is saturday night 18:30 local time just now and it has been a beautiful day.
    Well I was first a bit surprised getting a question on a problem I issued in october 2002.

    I can't remember exactly if I had to do anything, but my code is shown below. And I gladly contribute:


    In my "EventClassModule" I have the following code:

    Option Explicit

    Public WithEvents App As Word.Application

    Private Sub App_WindowBeforeDoubleClick(ByVal Sel As Selection, Cancel As Boolean)
    ThisDocument.SpellingFlagg = True
    End Sub

    Private Sub App_WindowSelectionChange(ByVal Sel As Selection)
    If ThisDocument.SpellingFlagg = True Then
    On Error Resume Next
    '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
    If Sel.StoryType = wdEvenPagesFooterStory Or _
    Sel.StoryType = wdEvenPagesHeaderStory Or _
    Sel.StoryType = wdFirstPageFooterStory Or _
    Sel.StoryType = wdFirstPageHeaderStory Or _
    Sel.StoryType = wdPrimaryFooterStory Or _
    Sel.StoryType = wdPrimaryHeaderStory Then
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

    'Proceed:
    If ActiveDocument.Name = "Document in Microsoft Internet Explorer" Then
    MsgBox "Du m

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

    Re: Library diff between XP and 2000 (Office XP, Word 2002 SP-2)

    Hi Bj

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Library diff between XP and 2000 (Office XP, Word 2002 SP-2)

    I just tested on my Word 2002 SP-2, and the WindowSelectionChange event does fire as expected. Have you tried putting some very simple code in the event handler, such as Beep?

  8. #8
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: Library diff between XP and 2000 (Office XP, Word 2002 SP-2)

    Hi Kyle,

    I think Hans is the one who can explain this better to you than me.

    Anyway, the code I posted is created into every .dot file. Though I might think it is possible to have it in a Global template, but that I haven't tried yet.

    Have a nice night(?) 00:38

    Regards
    Bj

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

    Re: Library diff between XP and 2000 (Office XP, Word 2002 SP-2)

    Hi Hans.

    I did put a beep in the code and nothing. I've even used breakpoints and nothing. What is so odd is the the other events in my eventhandler do fire. Here is my eventhandler:

    Public WithEvents objWord As Word.Application
    Private Sub objWord_DocumentChange()


    If objWord.Documents.Count > 0 Then

    Dim i As Integer
    Dim oRange As Range
    Dim oDocument As Document
    Set oDocument = objWord.ActiveDocument
    Set oRange = oDocument.Content
    Dim strTemplateName As String
    strTemplateName = oDocument.AttachedTemplate.Name

    objWord.ScreenUpdating = False

    If Left(strTemplateName, 6) = "Normal" Then
    If oRange.Characters.Count = 1 Then
    oDocument.AttachedTemplate = g_sTEMPLATEPATH & "CONNETICSPortrait Blank Document.dot"
    oDocument.UpdateStyles
    Exit Sub
    End If
    End If
    End If


    End Sub

    Private Sub objWord_DocumentOpen(ByVal objDoc As Document)

    Dim i As Integer

    With objDoc.ActiveWindow
    .View.Type = wdPrintView
    .ActivePane.View.Zoom.PageFit = wdPageFitBestFit
    .View.TableGridlines = True
    End With


    ActiveWindow.Caption = objDoc.Path + "" + objDoc.Name

    If objDoc.TrackRevisions = True And objDoc.ShowRevisions = False Then
    objDoc.ShowRevisions = True
    aretval = MsgBox("TrackChanges is currently on and the revisions are hidden." + Chr(13) + _
    "Do you want to disable TrackChanges and accept changes?", vbExclamation + vbYesNo, "Track Changes Warning")
    If aretval = vbYes Then
    objDoc.TrackRevisions = False
    objDoc.AcceptAllRevisions
    End If
    End If

    If objDoc.TrackRevisions = False And objDoc.ShowRevisions = False And objDoc.Revisions.Count > 1 Then
    objDoc.ShowRevisions = True
    bretval = MsgBox("There are revisions within the document that are hidden." + Chr(13) + _
    "It is recommend that they be accepted or rejected at this time." + Chr(13) + _
    "Would you like to accept or reject now?", vbExclamation + vbYesNo, "Track Changes Warning")
    End If

    If bretval = vbYes Then
    objDoc.TrackRevisions = False
    objDoc.AcceptAllRevisions
    End If


    End Sub

    Private Sub objWord_WindowActivate(ByVal Doc As Document, ByVal Wn As Window)
    On Error Resume Next

    Wn.Caption = Doc.Path + "" + Doc.Name

    End Sub

    Private Sub objWord_WindowSelectionChange(ByVal Sel As Selection)


    On Error Resume Next

    'using isObjectValid because during PDF conversion, selection object is deleted or no
    'longer available.

    If IsObjectValid(Sel) = True Then
    If Sel.Information(wdInHeaderFooter) Then
    modTemplateType.TemplateType
    If blnSubmission = True Then
    ActiveWindow.View.seekView = wdSeekMainDocument
    ShowHeaderInfoForm
    End If
    End If
    End If

    End Sub

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Library diff between XP and 2000 (Office XP, Word 2002 SP-2)

    Does your objWord variable get initialized correctly? I have attached a document (zipped) with your WindowSelectionChange event procedure; I had to comment out some references to code I don't have, but it prevents me from entering Header and Footer view.
    Attached Files Attached Files

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

    Re: Library diff between XP and 2000 (Office XP, Word 2002 SP-2)

    It does not work for me. I unloaded all my global templates and initialized the objWord variable a few times, but I can still view the header by double-clicking.

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Library diff between XP and 2000 (Office XP, Word 2002 SP-2)

    The doc I posted initializes objWordDoc automatically. I can't explain this; it would seem that there is something wrong with your Word installation. Try the steps outlined in Phil Rabichow's <!post=Systematic Approach to Behavioral Problems in Word (97/2000),197827>Systematic Approach to Behavioral Problems in Word (97/2000)<!/post>.

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

    Re: Library diff between XP and 2000 (Office XP, Word 2002 SP-2)

    Thanks Hans. I don't think this would be the problem because it does not work on all the XP machines at my office. I wonder if it has something to do with how my options are set in Word. The other thing that is odd is that the other events in the eventhandler do fire and work. Thanks again.

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Library diff between XP and 2000 (Office XP, Word 2002 SP-2)

    Sorry, I can't find anything in either the Knowledge Base or the newsgroups about WindowSelectionChange not firing.

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

    Re: Library diff between XP and 2000 (Office XP, Word 2002 SP-2)

    Hi Hans,

    Just wanted to let you know that I solved the problem. In addition to the register event handler in my AutoExec I also had a macro that sets the options within Word. My set options macro was erroring and it was not evident because of the on error resume next statement. What made it so difficult to identify is that all the other application events in my EventHandler would fire, but because of the error in my set options macro i guess things were not completely registering. Thanks for your help.

Page 1 of 2 12 LastLast

Posting Permissions

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