Results 1 to 6 of 6
  1. #1
    Ensleigh_IT
    Guest

    Updating fields in AutoOpen macro

    I have a user who is suffering from Word 97's NumPages field bug, whereby he gets things like "Page 5 of 1" in a header. I've given him a macro, on a toolbar button, to update fields, to correct the error. (I settled on View, Header/Footer, ctrl-a, F9, though I've tried other variants, eg changing view, with the same results.) That macro works fine, but if we put the same code in a macro called AutoOpen, to run automatically every time a file is opened, it doesn't correctly update the fields. In fact, it seems to update the first two pages, as if it were only a two-page document (giving "1 of 2", "2 of 2", "3 of 1", "4 of 1"). And advice would be appreciated!

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

    Re: Updating fields in AutoOpen macro

    I've led a charmed life and never had to deal with this particular one.[img]/w3timages/icons/crazy.gif[/img]
    Would something like the following work?:

    <pre>Sub UpdateAllStoryFields()
    Dim rngStory As Range
    For Each rngStory In ActiveDocument.StoryRanges
    rngStory.Fields.Update
    Next rngStory
    End Sub
    </pre>


  3. #3
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Updating fields in AutoOpen macro

    I don't know whether this is of any help to you- the numpages bug was fixed by Office 97 SR-2. It surfaced again in Word 2000, and was fixed by by SR-1a.

    The other way to get around it would be to attach it to Printing rather than to the AutoOpen- although Micrsoft say that printing will actually correct the problem.

    Have a look at an earlier post for some links about that problem.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  4. #4
    Ensleigh_IT
    Guest

    Re: Updating fields in AutoOpen macro

    Thanks. It works as well as a couple of other macros that we've tried. That is, if called AutoOpen, it apparently doesn't run when docs are opened; but if run from Tools, Macro, Macros it does work. Weird!

  5. #5
    Ensleigh_IT
    Guest

    Re: Updating fields in AutoOpen macro

    Thanks. We do have 97 SR-2, but the bug still bites! Printing prints correctly, and going in and out of Print Preview corrects the numbers in the screen display. We'd still like to get it fixed in the display, as soon as docs are opened.
    Let me have a look at those links you mentioned ...

  6. #6
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,048
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Updating fields in AutoOpen macro

    If the macros are in your templates, they may need to be in an AutoNew macro.

    I suspect that you have your macro in a global template (other than Normal.dot). If so, it won't run as AutoOpen (or AutoNew).

    You can put an AutoOpen macro in your document templates that calls a macro in a global template.

    Sub AutoOpen()
    Application.Run.MacroName:="myGlobalMacro"
    End Sub

    See http://www.addbalance.com/usersguide/templates.htm for more on global templates (and templates in general).
    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
  •