mbaasebo.blogg.se

How to add a button in word that shows and hides text
How to add a button in word that shows and hides text









how to add a button in word that shows and hides text

At vero eos et accusam et justo duo dolores et ea rebum. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. The text is now within the content-div and we are also now able to apply correct height and line-height settings. The content control that was just exited is NOT the one with the Tag value ckSidejobs, then do nothing.Starting from your fiddle and wrapped the content into a with a default class of content, used for selection and a class called hideContent which will be swapped with showContent when clicking the show more/show less link. What this says is "If the content control that was just exited is the one with the Tag value ckSidejobs, then make the range of the bookmark named bkSidejobs visible (= not hidden) if the check box is checked, or make it hidden if the check box is not checked. If If ContentControl.Tag = "ckSidejobs" Then Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) This thread, create the ContentControlOnExit event handler with the following contents: The different prefixes to avoid confusion in the code.)įinally, using the steps I outlined for you in (Actually, you could use the same name for the check box and the bookmark, but I recommend using Next, click in the check box content control, click the Properties button on the Developer tab, and enter a name in the Tag box let's call that ckSidejobs. While the text content control and itsīookmark are selected, go to the Font dialog and turn on the Hidden formatting. Let's say you name the bookmark bkSidejobs. Select the text content control and insert a bookmark around it, not including the tab character that precedes it. Set up the arrangement shown in the second screen shot. If you're satisfied with just hiding/displaying the tab and text content control based on the state of the check box, you don't need a building block at all, which eliminates any problems involved in inserting and deleting a building block.

how to add a button in word that shows and hides text

Instead, you can use a Select Case structure, which executes exactly one of the Case groups within it.ĪctiveDocument.Bookmarks("bkSidejobs"). = _ĪctiveDocument.Bookmarks("bkOtherCondition1"). = _ĪctiveDocument.Bookmarks("bkOtherCondition2"). = _ For more than three possible values, the first two methods become cumbersome.This works exactly the same way as multiple If structures, just with fewer lines. You can write a single structure using If. If.Each time the handler runs, only one of the If conditions will be true, so only that one will execute. You can write a separate If.Then.End If structure for each value.

#HOW TO ADD A BUTTON IN WORD THAT SHOWS AND HIDES TEXT CODE#

The way you code it to handle multiple check boxes is to test the Tag (or the Title) for each possible Second, the document (or its template) can have only one event handler named ContentControlOnExit, which is called when the cursor exits any content control. Up to you to make sure the values you give them are unique.]

how to add a button in word that shows and hides text

However, the Tag and Title values of content controls don't behave the same way, so it's If you try to add another bookmark with an existing name, the existing bookmark is automatically deleted. [Note: A Wordĭocument can't contain two or more bookmarks with the same name. Also, each bookmark that surrounds a text content control must have a different bookmark name. Since you mention having "several places" with the same setup, if they'll all be in the same document, then you need to know a few more things.įirst, each check box content control in the document must be given a different Tag value so the macro can identify which one triggered the event.











How to add a button in word that shows and hides text