Share via

Optional Paragraphs - use Building Blocks?

Anonymous
2015-02-26T19:45:16+00:00

I'm creating a template for a document that has several optional paragraphs.  I know how to easily use a Building Block Content Control for most of them, however, there is one place in the document where you either insert a certain paragraph or you insert nothing at all. 

How can I set up this situation so that if the paragraph isn't needed, then the content control - and the paragraph which contains it - get deleted?

I'm thinking I need to create a procedure for the ContentControlOnExit event, but I'm not exactly sure what that procedure might be.

Any help is greatly appreciated.

Thanks,

Jeri

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

Anonymous
2015-02-28T01:04:26+00:00

Charles ~

Thank you so much for your help with this.  I did finally get it to work by using a building block galler content control.  If the paragraph isn't needed they select an "empty building block" that actually contains a bookmark. 

When the ContentControlOnExit event occurs Word searches for a ContentControl with the specified title and if the bookmark exists it deletes the content control, the bookmark, and the paragraph.

I probably made it more difficult than it needed to be, but it works!

Thanks again,

Jeri

Was this answer helpful?

0 comments No comments

7 additional answers

Sort by: Most helpful
  1. Anonymous
    2015-02-26T23:23:58+00:00

    Hmm.  That's an interesting solution.  I, too, abhor empty paragraphs in Word used for spacing and have the entire document set to use "Body Text" with 12 pt after paragraph spacing.  That alone is going to create a big learning curve for the users, much less indicating that it's only a "sometimes" rule.  :)

    Maybe I should look at creating a ribbon control that they can click if they want the paragraph inserted and then create a hidden bookmark at the location.  The code could then insert the paragraph or not, but either way there is no empty paragraph to deal with.

    Thoughts?

    Was this answer helpful?

    0 comments No comments
  2. Charles Kenyon 167.7K Reputation points Volunteer Moderator
    2015-02-26T21:27:51+00:00

    I normally abhor empty paragraphs in Word used for spacing. This said, in this situation, I would turn off the automatic spacing between paragraphs, for these paragraphs, and use an empty paragraph with no space before or after.

    That is, create it so that the empty paragraph choice, by itself, does not look like there is something missing.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2015-02-26T20:15:25+00:00

    Charles,

    Thank you for your response.  Unfortunately, your solution is the one I've tried.  If option A is selected (the desired paragraph with a leading empty paragraph), then all is well.  However, if option B is selected (an empty paragraph), the document is left with 2 empty paragraphs, when what is needed is to remove the empty paragraph altogether.

    I'm not adverse to adding VBA code to the document (it already has quite a bit), I'm just not sure what to have the code do.

    Also, I don't see how a Userform would work because of the way the document is to be formatted.  Hopefully the example below will help me explain the situation better:

    This is a boilerplate paragraph.  This is a boilerplate paragraph.  This is a boilerplate paragraph.  This is a boilerplate paragraph.  This is a boilerplate paragraph.  This is a boilerplate paragraph.  This is a boilerplate paragraph. 

    This is another boilerplate paragraph.  This is another boilerplate paragraph.  This is another boilerplate paragraph.  This is another boilerplate paragraph.  This is another boilerplate paragraph.  This is another boilerplate paragraph.  This is another boilerplate paragraph. 

    [This is where the building block content control goes]

    This is yet another boilerplate paragraph.  This is yet another boilerplate paragraph.  This is yet another boilerplate paragraph.  This is yet another boilerplate paragraph.  This is yet another boilerplate paragraph.

    Was this answer helpful?

    0 comments No comments
  4. Charles Kenyon 167.7K Reputation points Volunteer Moderator
    2015-02-26T20:01:28+00:00

    I might create building blocks that contain (1) the desired paragraph with a leading empty paragraph and (2) simply an empty paragraph. Create a content control that chooses between them.

    An onExit procedure depends on the ability and willingness to run macros from your template.

    Automated Boilerplate Using Microsoft Word

    If you are going to use macros, you might as well bite the bullet and create a UserForm.

    Create a Simple Userform

    Create & Employ a Userform

    Was this answer helpful?

    0 comments No comments