Results 1 to 14 of 14
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Application Events

    We have written a Class Module with Word Events to trap the DocumentOpen event and post a warning if the document contains a letterhead image that is not currant. This functionss as expected most of the time. However, on some PCs, if Word is not loaded and loads with the document at issue, the warning NEVER displays. Is there some setting that controls this?

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Have you tried the simpler old way of naming macros in a standard module either AutoOpen or AutoNew?
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Why do you need to trap the DocumentOpen event via a Class Module? Surely you could use a Document_Open macro for that???
    Last edited by macropod; 2016-10-29 at 22:41.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  4. #4
    5 Star Lounger Lugh's Avatar
    Join Date
    Jun 2010
    Location
    Indy
    Posts
    627
    Thanks
    168
    Thanked 77 Times in 68 Posts
    Quote Originally Posted by richardbarrett View Post
    a letterhead image that is not currant.
    Is there a raisin for this?
    Lugh.
    ~
    Windows 10 Pro x64 1607; Office 2016 (365 Home) x32; Win Defender, MBAM Pro

    ASRock H97 Anniversary; Xeon E3-1231V3 (like i7)
    Gigabyte GeForce GTX 970; 12GB Crucial DDR3 1600
    Logitech MX Master mouse; Roccat Isku kb

  5. #5
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Quote Originally Posted by Lugh View Post
    Is there a raisin for this?
    That's just grape, another troublemaker with a dry sense of humour.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  6. The Following User Says Thank You to Andrew Lockton For This Useful Post:

    Lugh (2016-11-28)

  7. #6
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts
    Richard,

    Macropod suggested what I do all the time--put your code in a sub in the ThisDocument module and name it Document_Open.

    K

  8. #7
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts
    I want this to run on every document that opens? Will AutoOpen (placed where?) do that?

  9. #8
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    A sub called AutoOpen can be placed into any regular module and will automatically run when a saved document is opened.

    A sub called AutoNew can be placed into any regular module and will automatically run when a new document is created either by using File>New or double clicking a template.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  10. #9
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    A Document_Open sub placed in a template will act on every existing document attached to that template whenever it's opened. A Document_New sub placed in a template will act on every new document attached to that template when the document is created.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  11. #10
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts
    It was my understanding that Microsoft was deprecating the "Auto" macros.

    The Auto macros you mention must be in "any regular module" in any template stored in the Startup folder, correct?

  12. #11
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Richard

    I don't know what the timeline is for removing the Auto-macros. They still work in Word 2013 and I haven't tested in Word 2016 but I think they are still there too.

    According to http://word.mvps.org/faqs/macrosvba/documentevents.htm it looks like an addin in the startup folder is no good for these macros (and the Document_ ones too). You may need to put them into Normal if you want them to operate on all documents regardless of the attached template.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  13. #12
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts
    Quote Originally Posted by Andrew Lockton View Post
    A sub called AutoOpen can be placed into any regular module and will automatically run when a saved document is opened.

    A sub called AutoNew can be placed into any regular module and will automatically run when a new document is created either by using File>New or double clicking a template.
    The AutoOpen and AutoNew macros will run if place in either the normal template or the attached template for a document. They will not run in other global templates.
    Charles Kyle Kenyon
    Madison, Wisconsin

  14. #13
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts
    Quote Originally Posted by richardbarrett View Post
    We have written a Class Module with Word Events to trap the DocumentOpen event and post a warning if the document contains a letterhead image that is not currant. This functionss as expected most of the time. However, on some PCs, if Word is not loaded and loads with the document at issue, the warning NEVER displays. Is there some setting that controls this?
    You should be using templates rather than old documents as the basis for new letters. It is possible (although not a trivial task) to keep your current letterhead in a single repository and have letter templates update to that upon the creation of a new document.

    I am a lawyer, and for my purposes, using old documents as the basis for new ones runs an unnecessary risk of a breach of confidentiality.
    Charles Kyle Kenyon
    Madison, Wisconsin

  15. #14
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by richardbarrett View Post
    It was my understanding that Microsoft was deprecating the "Auto" macros.
    That's true - they have been deprecated already. The real issue is whether & when MS will release a Word version that no longer supports them; deprecation doesn't mean the functionality (which has been superceded by the Document_New, Document_Open & Document_Close macros) will be removed from any existing version. WordBasic was deprecated once Word VBA was introduced nearly 20 years ago, yet it's still supported.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

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