Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    May 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AutoExec Macro - enough to drive a person insane! (EN / MS Word 97)

    Well - perhaps someone out there can explain to me the logic behind this one - or how to deal with it in any case.

    I'm working on a macro that needs to run whenever a user opens a document, or creates a new one from a template.
    The macro must run as soon as a file is opened - regardless of what the file is.
    In order to cover all possibilities, I've setup AutoExec, AutoNew and AutoOpen macros in a global template (globals.dot).
    For maintenance purposes, I'd like to keep the macro that is to run in a second global template (printer.dot), though
    I have also tried including it in the main global template and it makes no difference one way or the other.

    Everything functions as it should - except the AutoExec macro.

    AutoExec runs in the following situations if the Word is not already open:
    - When the user launches Word via desktop icon or start menu
    - When the user opens a document directly from Explorer
    - When the user uses the "New Office Document" shortcut under the start menu
    - When the user uses the "Open Office Document" shortcut under the start menu


    I'm aware that the AutoExec runs before any global templates are loaded by Word,
    so I use .OnTime to delay the macro for a bit.

    In each case, the macro functions as it should, EXCEPT when the user uses the
    "Open Office Document" shortcut under the start menu.


    In this case, AutoExec will run (I use a msgbox to test) , but it will not run the other macro ( contained in printers.dot).
    No error messages, no nothing. I know the script works because, as I said, if the user launches Word in any other way
    (via desktop shortcut or explorer) then the AutoExec macro does what it is supposed to. It is in this ONE scenario only
    that it decides not to cooperate.

    If anyone has an explanation for this - I'd sure appreciate hearing it.

    BTW - While troubleshooting this problem I disabled the scripts in the AutoOpen and AutoNew -
    using only a message box so I could tell what script was running when. This ruled out the possibilty
    of there being a conflict between the different auto macros.

  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: AutoExec Macro - enough to drive a person insane! (EN / MS Word 97)

    It's not obvious to me how that "shortcut" works; it's not like a normal shortcut.

    Does this workaround help: before running the macro check the .Installed property of printer.dot in the add-ins collection and, if not installed, load it before proceeding? (I think the one you want is Installed, but it might be something else... haven't double-checked.)

  3. #3
    New Lounger
    Join Date
    May 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoExec Macro - enough to drive a person insane! (EN / MS Word 97)

    I checked Templates and Add-Ins and the template is installed.

    Although the "Open Office Document" shortcut initiates AutoExec, it does not execute any global macros - regardless of what I set .OnTime to. My workaround was to put the same script into the AutoNew for each template and then it will run as it should - even from this shortcut.

    I just find it odd that AutoExec will execute properly in every other situation of starting Word, except through the use of this shortcut.

  4. #4
    Star Lounger
    Join Date
    Nov 2001
    Location
    Illinois, USA
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoExec Macro - enough to drive a person insane! (EN / MS Word 97)

    It is pretty odd! The shortcut runs OSA.EXE the Office Startup Application. There is some info at: http://support.microsoft.com/default.aspx?...b;en-us;Q165071 They say it initializes automation and code that is shared by the Office applications so that the applications start faster. Maybe there is some quirk in there that makes it bypass the global macros.

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

    Re: AutoExec Macro - enough to drive a person insane! (EN / MS Word 97)

    u need to check whether the template is installed WHILE the AutoExec is running.

    One way to do this is to insert code in AutoExec to list the entire Templates collection just before you believe that the template of interest is needed.

    Using Debug.Print is best, but you could use a MsgBox to list the templates.

Posting Permissions

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