checkbox hidden text

S

San

Hi,

If a checkbox is marked in my form I want that a text appears further down
in the document, if not marked the text has to disappear
Can I use the If then else function ?
I'm not used to work with VBA or macro's .; so if possible with the if then
function it would be great !!

thanks a lot !

San
 
H

Helmut Weber

Hi San,

I never liked forms. Checkboxes there should run macros
on entry and on exit. According to my experience, it's not
reliable. And even if was, on entry or on exit doesn't react
to a change of the checkbox. The code attached to it fires
on entry, which is somewhat confusing, or on exit, which
is impossible, if there is only on formfield at all,
or on both entry and exit, which is still more confusing,
as it doesn't fire at all, if there is only one formfield.

Use a checkbox from the control toolbox,

and try this code, to get you started.

Private Sub CheckBox1_Change()
If CheckBox1.Value = True Then
ActiveDocument.Paragraphs(10).Range.Text = "xxxx" & vbCrLf
Else
ActiveDocument.Paragraphs(10).Range.Text = "" & vbCrLf
End If
End Sub

Though, this isn't the end of the story,
and there are some surprises waiting for a beginner.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top