Share via

Automatically hiding text boxes

Anonymous
2020-05-24T13:37:06+00:00

Hi,

I am using mail merge to pull in a lot of questions and answers to a form which will be listed in a text box.  on some occasions the list may be too big for the page, so i am using the flow feature to run into a second text box on a continuation page which I would only like to be included in the final PDF if it has content in it.  Is there a way to hide a text box in such a way that it omits that page if it is not used? 

Also, is there a way to then reference which page number the continuation page will be on if it does end up being used, if it remains empty have "N/A" in the reference area instead?

I hope this makes sense.  Thank you.

Ben

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

4 answers

Sort by: Most helpful
  1. Jay Freedman 207.7K Reputation points Volunteer Moderator
    2020-05-25T00:33:25+00:00

    I would suggest using a table instead of a series of text boxes. If the content of a table exceeds the length of the page, it simply continues on the next page. No extra content = no extra page.

    If you're using text boxes because they can be positioned on the page wherever you want them, you can do that with a table too. Right-click in the table, click Table Properties, and click the Around button in the dialog; then click the Position button and choose the location. Once the table is "floating" you can also drag it by the little square near the top left corner.

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments
  2. Doug Robbins - MVP - Office Apps and Services 323K Reputation points MVP Volunteer Moderator
    2020-05-26T00:59:46+00:00

    Can you provide more information about the data?  Is the second textbox required if some records have data in more fields than others, or do all records have data in all of the fields, but it is the length of the data that varies so that sometimes the second textbox is required?

    If you send me a copy of the mail merge main document and the data source, referencing this thread in the covering email message, I will take a look at the issue.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Jay Freedman 207.7K Reputation points Volunteer Moderator
    2020-05-25T20:13:10+00:00

    That does make a big difference: a table cannot continue to a page other than the next one (I haven't tried putting a table in a linked text box to see if that works, but then the table wouldn't be necessary).

    It's easy to hide an empty text box manually (use the Selection pane and click the "eye" icon next to the box's name), but that doesn't remove/omit the whole page. To do more, you could insert a bookmark that extends from the page break before the continuation box (which I assume you have in the main merge file to make the box appear on an otherwise empty page) past the paragraph that contains the box's anchor. Then a macro can delete the bookmark's range if the box is empty. That macro would look something like this:

    Sub DeleteContinuationBoxPage()

        Dim shp As Shape

        Set shp = ActiveDocument.Shapes("continuation")

        If Replace(shp.TextFrame.TextRange.Text, vbCr, "") = "" Then

            ActiveDocument.Bookmarks("deleteme").Range.Delete

        End If

        Set shp = Nothing

    End Sub

    [Note: you can assign a name to a text box in the Selection pane, and the above code assumes the box is named "continuation" and the bookmark is named "deleteme".]

    This macro would have to run after the merge and before the save to PDF. Some third-party merge software will let you run a macro of your choice on completion; otherwise you have to remember to do it manually.

    The macro can be extended to handle the page reference (an ordinary cross-reference in Word can't show a "N/A" result).

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  4. Anonymous
    2020-05-25T06:27:28+00:00

    Thanks for the reply, however the continuation page wont be the next oage in the sequence of page, it will be around 4 pages later, this is ehy i need to use text bixes, unless there is a way to acheive this with tables too?

    Was this answer helpful?

    0 comments No comments