Share via

Keep with Next Macro

Anonymous
2011-08-23T19:28:29+00:00

I'm hoping someone can help me with a Keep With Next macro.  I don't see that it's listed in any of the options in the command buttons selections so I'm looking to add it programatiacally with a Macro which I'll put on one of the toolbars.  Does anyone have something like this?  I'd like it to simply toggle the selected paragraph. 

We use it quite often and going to Format/Paragraph/Line and Page Breaks Tab/select or deselect Keep with Next option is a lot of work.  Clicking a button makes WAY more sense. 

Can someone help me out with a macro for this please?

I thank you for your help in advance! 

~Dax

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2011-08-23T20:07:37+00:00

Perhaps this?

Sub ToggleKeepWithNext()

    With Selection.Paragraphs(1)

        .KeepWithNext = Not .KeepWithNext

    End With

End Sub

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Suzanne S Barnhill 278.1K Reputation points MVP Volunteer Moderator
    2011-08-24T02:13:40+00:00

    Not only can you assign a keyboard shortcut to ParaKeepWithNext, you can assign it to a toolbar button. For a nice-looking button icon, see http://sbarnhill.mvps.org/WordFAQs/CustomToolbar.htm. The button has the added advantage that when you click in a document, the on/off status of the button shows whether the property has been applied to the paragraph at the insertion point.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-08-23T21:10:56+00:00

    YES!!!  That rocks!  Thank you!!!!  ~Dax

    Was this answer helpful?

    0 comments No comments
  3. Charles Kenyon 167.7K Reputation points Volunteer Moderator
    2011-08-23T21:00:12+00:00

    Even easier, how about attaching the command to a shortcut? It is the format command ParaKeepWithNext.

    Tools > Customize > Keyboard

    One other method would be a Style with the setting for the following Style reverting to the original Style.

    Was this answer helpful?

    0 comments No comments