Results 1 to 8 of 8
  1. #1
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Levin, Manawatu-Wanganui, New Zealand
    Posts
    324
    Thanks
    9
    Thanked 28 Times in 26 Posts

    autoNew vs document_new (Word 2000)

    Hi folks
    Can someone pleas explain the distinction between the AutoNew procedure and new_document events.
    Typically I might call AutoNew from a module which displays a form.

    I figured that
    sub document_new
    frmFormName.show
    end sub

    may do something similar but it doesnt ..

    Cheers & thanks
    Geof

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Boston, Massachusetts, USA
    Posts
    205
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: autoNew vs document_new (Word 2000)

    Autonew is a macro that runs every time a new document is created. You name it AutoNew and you don't even need to call it in another macro. New Document event you need to call. You cannot have a macro named New Document and have it automatically run when a new document is created.
    At least, that's my spin on it.
    Hope that helps.

  3. #3
    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

    Re: autoNew vs document_new (Word 2000)

    You might want to look at Running a macro automatically when a document is created, opened or closed.

    A procedure named AutoNew or named Document_New (but not new_document) will run whenever a new document is created based on the template containing the procedure. Document_New may also be triggered even if placed in a global template.
    Charles Kyle Kenyon
    Madison, Wisconsin

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

    Re: autoNew vs document_new (Word 2000)

    Charles,

    That's a good link as Dave Rado's article covers the pertinent information. One thing to clarify though, Document_New will not run from a global template, unless you are creating a new document based on that global template (which one wouldn't want to do).

    The topic can be confusing because there are actually three possible New document event procedures: Document_New (which gets placed in the ThisDocument module of a template that you base documents on); AutoNew (which typically would get placed in Normal.dot though as Dave points out, that can be a bad idea); and the application-level Document_New event.

    Distilling all of these choices down, the best bet for most situations is to use the Document_New event procedure in an attached template. One advantage of using this, not mentioned in Dave's article, is that Document_New, being by default a Private Sub, will not appear in the user's available list of macros, while AutoNew will.

    Gary

  5. #5
    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

    Re: autoNew vs document_new (Word 2000)

    You can set the Document_New to run from a global by putting it in a class module.
    Charles Kyle Kenyon
    Madison, Wisconsin

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

    Re: autoNew vs document_new (Word 2000)

    Are you talking about the application-level "Application_DocumentNew" event procedure (which goes into a class module) or are you talking about putting "Document_New" in a class module? - if the latter, I'm unfamiliar with doing that - what are the uses for that?

    Gary

  7. #7
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Levin, Manawatu-Wanganui, New Zealand
    Posts
    324
    Thanks
    9
    Thanked 28 Times in 26 Posts

    Re: autoNew vs document_new (Word 2000)

    Thanks to Rebecca, Charles & Gary
    The topic just gets better & better. I haven't used 'this document" much in the past to store procedures.
    Maybe I will in the future and store document_new() procedures there instead of using the AutoNew()

    If I understand what I am reading ...

    private sub document_new()
    frmFormName.show
    End sub

    stored in "This document" of a template will do the same thing as "AutoNew()" stored in a module and will not show in the users list of macros.

    Have I bee n missing anything by not using 'this document"

    Cheers & thanks

    Every day is a school day.
    Geof

  8. #8
    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

    Re: autoNew vs document_new (Word 2000)

    Hi Gary,

    I'm out of my depth here. I'm talking about class module events described at Writing application event procedures. Sorry for the confusion.
    Charles Kyle Kenyon
    Madison, Wisconsin

Posting Permissions

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