Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Chantilly, VA USA
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro Operate Inconsistently (Word97 SR2)

    I've created several little macros in Word97SR2, using the Macro Record Feature. Each macro applies a certain Style to the current paragraph, then moves the cursor down one paragraph. The relevant parts of one such macro are:
    Selection.Style = ActiveDocument.Styles("Para 2")
    Selection.MoveDown Unit:=wdParagraph, Count:=1
    The macros don't operate consistently. They always apply the Style, but more often than not, don't jump down to the next paragraph. But of course, sometimes they do.

    Any idea what's at issue here?

    Thanks

    Don

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

    Re: Macro Operate Inconsistently (Word97 SR2)

    Don,

    That sounds interesting, but not enough information to make any sense as to what's going on.
    Code derived from the macro recorder often isn't flexible enough to deal with situations that are a bit different from those that were in effect when the macro was recorded.
    Can you attach a small sample document to show what the paragraphs look like (and even better, annoted along the lines of "it works right here; it doesn't work right here), along with the code?

    Gary

  3. #3
    Lounger
    Join Date
    Jul 2001
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro Operate Inconsistently (Word97 SR2)

    I have also found macros operating inconsistently. For example I have one that subscripts the character just keyed which works about 9/10ths of the time. I sometimes wonder whether Word is so complicated that one of these abstruse mathematical theories (chaos theory?) applies.
    (Imagine a chaos theory smiley here).
    Isabel

  4. #4
    Star Lounger
    Join Date
    Jan 2001
    Location
    Chantilly, VA USA
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro Operate Inconsistently (Word97 SR2)

    Gary, here's a sample document that should have my styles in it.

    I haven't noticed any particular consistency or inconsistency about when it does and doesn't work. It does seem more likely to run properly when I call it via Tools > Macro than when I run it via the keyboard shortcut. But the keyboard shortcut always changes the style.... it just doesn't complete the macro and drop down to the next paragraph.

    Thanks for the help!

    Don
    Attached Files Attached Files

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

    Re: Macro Operate Inconsistently (Word97 SR2)

    Don, I've got the document (and saved a copy to my PC), but the macro doesn't seem to be there - presumably the macro is not in the document, but in the Proposal template.

    Would it be possible to post the relevant code from Proposal.dot, which relates to these macros?

    Gary

  6. #6
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro Operate Inconsistently (Word97 SR2)

    Hi Don,

    Perhaps it works better if you make sure whole paragraphs are selected before applying the style:
    <pre>Selection.Expand Unit:=wdParagraph</pre>

    In Word2000, this is absolutely necessary, because Word applies only the font formatting, not the style, if only part of a paragraph is selected (one of the most hare-brained changes MS has come up with in Word2000).

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

Posting Permissions

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