Results 1 to 11 of 11
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Events fired when Word starts? (WinXP/ Word 2003)

    Hi,

    Here's one that really puzzles me.

    Got a .dot-file - placed in startup folder.
    Once it launches it builds a menu point available on application level.

    In the .dot file there are AutoExec, AutoOpen and Autonew procedures. (All sub MAIN and then some code going to other subs)
    For some reason, whenever I open an ordinary Word file it causes an error with the message "The command cannot be performed because a dialog box is open. Click OK, and then close open dialog boxes to continue"

    The odd thing is - no dialog boxes are open. Word has been shut down completely prior to opening the doc and I have inserted msgboxes in the sub MAINs for debugging purposes and this event seems to fire before the AutoExec main - which means that as far as I know - none of my code has been triggered at this stage.

    Unfortunately the first error dialog box doesn't offer debug facilities only an "End" option.

    So my question is: What events that my code trigger are fired prior to the AutoExec?

    Tia
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

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

    Re: Events fired when Word starts? (WinXP/ Word 2003)

    Do you use Norton Anti Virus (NAV)? If so, disable the Office Plug-In:
    - Start Norton Anti-Virus
    - Click Options.
    - Click Miscellaneous.
    - Clear the "Enable Office Plug-in" check box.
    - Click OK.

    If that doesn't help, what other add-ins/global templates do you have in the Startup folder?

  3. #3
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Events fired when Word starts? (WinXP/ Word 2003)

    No NAV used.

    Problem disappears when I remove my file that creates the menupoint from the startup. So I'm close to 100% certain that it must be the source of the problem. However I have up til now been of the understanding that AutoExec always was the first event to fire...??

    The file do contain additional references to other standard files set in the VBE at design time. When are they loaded ?
    - do you think it could be them causing this problem?
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

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

    Re: Events fired when Word starts? (WinXP/ Word 2003)

    I don't know exactly how Word starts.

    It's obvious that your add-in has something to do with the error message, but it could be interference with another add-in, that's why I asked which other add-ins are loaded. I don't think that merely setting a reference in Tools | References... will cause the error message you get, but I can't be 100% certain.

  5. #5
    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: Events fired when Word starts? (WinXP/ Word 20

    When you say you are opening a document, are you using File>Open, or are you launching a DOC from outside Word? Does it make any difference or do you get the error either way?

    Actually, if I read your post correctly, Word is closed and you are lauching a DOC. This is a worst case scenario for unpredictable behavior because your add-in may have been written with the assumption that there would be a blank Document1 when Word was launched, rather than a not-yet-open document from the file system. See if any of the code in your add-in fails when there is no document open.

  6. #6
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Events fired when Word starts? (WinXP/ Word 20

    You nailed the problem here. It only happens when Word is launched "from outside" and no Activedocument is available.
    Problem seems to be related to the fact that there doesn't exist an Activedocument

    Thus I've gone through my code for Activedocument or it's likes then I've inserted as the first line in the Autoexec.main a msgbox that indicates where I am.
    The odd thing is that the error occurs before this first line is activated.

    This is the reason why I'm suspecting that it must be caused by a reference or its like as I would believe those are the only things fired before AutoExec??

    I've also deleted my Normal.dot to make sure I'm running on a "clean" version.

    Is files from the startup folder loaded differently to other files or are they just "opened as is" ?
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  7. #7
    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: Events fired when Word starts? (WinXP/ Word 20

    I think references will be directly loaded from disk and don't depend on what you might or might not have open in Word at the time. But I'm not very adventurous with references so I don't know.

    Can you use On Error Resume Next at the start of AutoExec and bypass or reschedule the procedure's actions based on the error number associated with "a dialog is open"?

  8. #8
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Events fired when Word starts? (WinXP/ Word 20

    Thanks, this gave me an idea...
    My msgbox though line 1, it didn't stop the AutoExec at it's line - it continued, but the msgbox got hidden behind the error dialog, so it seemed to appear after the error.

    My sub looked like this

    module name "AutoExec"

    sub main
    msgbox "AutoExec;Main"
    Toolbar_Delete 'Deletes old toolbar version
    Toolbar_Add 'Add or update with a new toolbar
    end sub

    The error was in the Toolbar_Add where I had an "activedocument.commandbars.add...." as I changed this to application level (application.commandbars.add) the error disappeared.

    Apologies for not having seens this before.
    Thanks for your efforts on this matter.

    Bests /H
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  9. #9
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Events fired when Word starts? (WinXP/ Word 20

    If a global template needs to refer to ActiveDocument, it is always best to include
    <code>
    If Application.Documents.Count > 0 Then
    ...
    End If
    </code>
    around the reference.

    StuartR

  10. #10
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Events fired when Word starts? (WinXP/ Word 20

    When Word is started via Automation, there is no ActiveDocument.

    If your Auto* macros are doing something that requires a document, then th macros need to check th eDocuments.Count.
    If 0, create a document for use during the macro, then close the document.

  11. #11
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Events fired when Word starts? (WinXP/ Word 20

    adding a reference does not cause any vba code to execute.
    however, trying to add a reference that is missing can cause an error.

Posting Permissions

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