Populated fields when checkbox selected

D

Debbiedo

I want to update some text boxes when a check box is selected.

I have 3 bookmarks labeled Text1, Text2 and Text3. When the user
selects the checkbox, a macro needs to be executed which populates
bookmarks TextA with data entered in bookmark Text1, TextB populated
with Text2 and TextC with Text3.

I need help with the macro or VBA script please.

I am using a MS Word 2003, protected form.

Thanks, Deb
 
O

old man

Hi,

I created a word document with a bookmark range around some text name text1.
I then created a form field with a checkbox name checkbox1 and a textfield
named texta. I assumed protection was without a password. Here is the code
that does what you wat (for one bookmark/formfield). You should add error
checking...


Private Sub CheckBox1_Click()
Dim wasprotected As Boolean
Dim protecttype As Integer

If Me.CheckBox1 Then
wasprotected = False
If ActiveDocument.ProtectionType <> wdNoProtection Then
protecttype = ActiveDocument.ProtectionType
ActiveDocument.Unprotect
wasprotected = True
End If

UserForm1.Texta.Text = ActiveDocument.Bookmarks("text1").Range.Text

If wasprotected Then
ActiveDocument.Protect Type:=protecttype
End If

End If

old man
 

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