Group:  Microsoft Word ยป microsoft.public.word.vba.userforms
Thread: Using Checkboxes to show and hide text in a word document

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Using Checkboxes to show and hide text in a word document
jedale[ at ]gmail.com 21.08.2006 19:14:34
I have a procedural document that has multiple paths that the user can
go down depending on what physically happens. I was wondering if there
was a way to set up a checkbox at each of these branches where a yes or
no question would be answered by using a checkbox to direct the user
down the correct procedural path.

I found a simple way to toggle text by the example at this site:
http://gregmaxey.mvps.org/Toggle_Data_Display.htm which I have been
able to switch over to use with a checkbox. The problem is that I have
to use a table to get it to do what I want. I have limited abilities
in VBA and thought that maybe it could be done without the table but I
just don't know where to start.

Specifically, I would like to link the text to the checkbox through a
bookmark system or something of the sort. I don't want the text to be
hard coded into VBA which will confuse others if they have to update
any of my documents in the future. I was hoping that somebody would
know where I could find an example of this type of code. I would think
that it has been done before but I can't seem to find much.

can anyone help me with this?
Thanks for your time.

Jeff

Re: Using Checkboxes to show and hide text in a word document
Cindy M. <C.Meister-C[ at ]hispeed.ch> 22.08.2006 14:51:08
[Quoted Text]
> Specifically, I would like to link the text to the checkbox through a
> bookmark system or something of the sort. I don't want the text to be
> hard coded into VBA which will confuse others if they have to update
> any of my documents in the future. I was hoping that somebody would
> know where I could find an example of this type of code. I would think
> that it has been done before but I can't seem to find much.
>
You could certainly put bookmarks around the text sections to identify
them. Then you can set the hidden font property, for example:
ActiveDocument.Bookmarks("Sec1").Range.Font.Hidden = True 'or false

Another possibility is to format each "section" with a unique style name
(the formatting of the styles can be identical). Then set the hidden
property for the style:
ActiveDocument.Styles("Sec1").Font.Hidden = true

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)

Re: Using Checkboxes to show and hide text in a word document
jedale[ at ]gmail.com 27.08.2006 19:35:22
Would it be to much to ask for a simple example of these two ways to
hide text? It would probably take me all day to figure it out. I have
next to none VBA skills. I would be greatful if you could send it to
me at "jedale at gmail dot com".

Thank you for your time.
Jeff

Re: Using Checkboxes to show and hide text in a word document
skatonni 31.08.2006 11:46:02
For an example of the first method see here for both table and bookmark:
http://vbaexpress.com/kb/getarticle.php?kb_id=754

I had to pass the checkbox value. Could be a Word version issue.
Private Sub CheckBox2_Click()
Call ShowHideBookmark(CheckBox2.Value)
End Sub

Sub ShowHideBookmark(CBValue As Boolean)

"jedale[ at ]gmail.com" wrote:

[Quoted Text]
> Would it be to much to ask for a simple example of these two ways to
> hide text? It would probably take me all day to figure it out. I have
> next to none VBA skills. I would be greatful if you could send it to
> me at "jedale at gmail dot com".
>
> Thank you for your time.
> Jeff
>
>

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net