Results 1 to 12 of 12
  1. #1
    New Lounger
    Join Date
    Sep 2001
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Tip of the Day (VBA / Word / 97-2K)

    I have a template (not attaching to any documents) that is loaded at startup of Word and need to display a Tip of the Day sub. I tried calling it from the AutoExec sub, but that didn't work. What am I missing?

    Thanks!

  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: Tip of the Day (VBA / Word / 97-2K)

    You could try using the Document_New event and check for the existence of only Document1 in the documents collection. I actually don't know whether Document_New fires in a global template.

  3. #3
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Tip of the Day (VBA / Word / 97-2K)

    If Word is set up to not open a new document on launch, then a Document_New event won't apply.
    Anyway, Document_New will only fire in a global template if/when a new document is created based on that template. To get a truly global document new event trap, you can use an application-level NewDocument event procedure (may not be available in 97).

    Decker225, can you provide more info: is there any other code in the AutoExec, and is that running, and only your tip of the day code isn't? - for instance, if you put:

    MsgBox "This is running from AutoExec in TemplateName on startup!"

    in the AutoExec, do you then get this message box on startup?

    What is the code you're using to try to make the tip o' the day appear?

    Gary

  4. #4
    New Lounger
    Join Date
    Sep 2001
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Tip of the Day (VBA / Word / 97-2K)

    Well, at this point I have only a msgbox line in the AutoExec. Actually, I have a module called AutoExec and within that I am using a sub called MAIN (which is acceptable according to the VBA help). The MAIN sub will eventually call the Tips form. Initially, I was calling a sub called AutoExec from a different module, but changed for clarification.

    Currently, not even the msgbox pops up. So I guess my first predicament is to figure out why that won't work. Any thoughts?

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

    Re: Tip of the Day (VBA / Word / 97-2K)

    Some commands cannot execute without an active document or until AutoExec reaches some point.

    Put some code in the AutoExec that delays display of your tip by, say, 2 seconds. That might do the deed.

    See the Help for the OnTime method.

  6. #6
    Lounger
    Join Date
    Mar 2001
    Location
    NSW, Australia
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Tip of the Day (VBA / Word / 97-2K)

    Have you ensured that AutoExec is in the normal template, and that your File Locations are pointing to the directory which holds normal.dot ?

  7. #7
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Tip of the Day (VBA / Word / 97-2K)

    Lorraine, I would disagree about locating the AutoExec in Normal.dot. The general consensus seems to be to leave Normal.dot as close to its default state as possible, and use global templates instead.

    Decker, The AutoExec in a global template in Startup should be running; a couple of questions:

    Are you sure the global template is in the Startup directory that you are pointed to? - to check this, after Word launches, go to Tools > Templates & Add-Ins and check to see if your global template is in the list of global templates and that it has a checkmark next to it. If it isn't, go to Tools > Options > File Locations and check which directory is indicated as the Startup directory, and then either move your global template to that location, or point to the directory that you have the global template loaded in.

    When you check the list of global templates and add-ins, are there any other global templates loaded?

    Gary

  8. #8
    Lounger
    Join Date
    Mar 2001
    Location
    NSW, Australia
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Tip of the Day (VBA / Word / 97-2K)

    Thanks Gary
    I understand the need to leave normal.dot as close to default state as possible. In our organisation, the only thing our AutoExec does is read an ini file in order to load our 9 global templates. The only other deviation we have from default is an AutoExit routine to remove any object addins and uninstalled addin references.

    Auto macros can be defined either globally or for a particular template. The only exception to this is the AutoExec macro, which will not run automatically unless it is stored in the Normal template.

  9. #9
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Tip of the Day (VBA / Word / 97-2K)

    Re: running AutoExec in a template other than Normal.dot, here's the VBA help on automacros:
    <hr>Just like other macros, auto macros can be stored in the Normal template, another template, or a document. In order for an auto macro to run, it must be either in the Normal template, in the active document, or in the template on which the active document is based. The only exception is the AutoExec macro, which will not run automatically unless it is stored in one of the following: the Normal template, a template that is loaded globally through the Templates and Add-Ins dialog box, or a global template stored in the folder specified as the Startup folder.<hr>
    At work (Word 2000 if that matters) we've got an AutoExec running in a global template in Startup, and it definitely does run!

  10. #10
    New Lounger
    Join Date
    Sep 2001
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Tip of the Day (VBA / Word / 97-2K)

    I appreciate the conversations about this.

    Gary, I do have my global template loaded at startup, and I also checked that using the same procedures you described. I am not sure why the AutoExec is not running. However, I am beginning to wonder if the template is not corrupt (gee, that never happens!). I am going to try the suggestions with a blank template and see what comes up. If that works, I will fix the corruption. I'll let you know.

    Thanks again!

  11. #11
    New Lounger
    Join Date
    Sep 2001
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Tip of the Day (VBA / Word / 97-2K)

    OK... here's the skinny... I inadvertantly had another AutoNew macro hidden in a long-forgotten module. That was the conflict, and I don't need to go into details about that obvious mistake. <img src=/S/bingo.gif border=0 alt=bingo width=15 height=22>

    Again, I appreciate the conversations because it brought some things that I hadn't thought of or tried before - the very essence of this Lounge at its best. Thanks to all!!!

  12. #12
    Lounger
    Join Date
    Mar 2001
    Location
    NSW, Australia
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Tip of the Day (VBA / Word / 97-2K)

    That's great Gary. I was going on info from my "bible" (Word Developers Kit - WordBasic) which did actually state that AutoExec had to appear in the normal template. Things are always moving on - great news for us.
    Thanks again.

Posting Permissions

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