• Application Events

    Author
    Topic
    #507405

    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?

    Viewing 7 reply threads
    Author
    Replies
    • #1582871

      Have you tried the simpler old way of naming macros in a standard module either AutoOpen or AutoNew?

      • #1585232

        I want this to run on every document that opens? Will AutoOpen (placed where?) do that?

    • #1582877

      Why do you need to trap the DocumentOpen event via a Class Module? Surely you could use a Document_Open macro for that???

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

    • #1582950

      a letterhead image that is not currant.

      Is there a raisin for this?

      Lugh.
      ~
      Alienware Aurora R6; Win10 Home x64 1803; Office 365 x32
      i7-7700; GeForce GTX 1060; 16GB DDR4 2400; 1TB SSD, 256GB SSD, 4TB HD

      • #1582985

        Is there a raisin for this?

        That’s just grape, another troublemaker with a dry sense of humour.

    • #1582996

      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

    • #1585242

      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.

      • #1585349

        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?

        • #1585778

          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
          [Fmr MS MVP - Word]

      • #1585719

        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.

    • #1585245

      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
      [Fmr MS MVP - Word]

    • #1585360

      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.

    • #1585720

      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 templatesrather 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.

    Viewing 7 reply threads
    Reply To: Application Events

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: