Toggle button code to insert user response into template

L

LisaM

Hello,

I've created a User Form to create content for a letter. This is the first
time I've ever used VB - I'm a complete Newbie - and I've had a lot of help
using an article I found online.

I have included toggle buttons in the form and what I would like them to do
is insert text into the letter when they're selected, but if they're not
selected, then the space where the bookmark is in the letter remains blank.

This is the segment of code that concerned the toggle button and what the
bookmark was supposed to fill in with:
If togPartAwardsText.Value = True Then
.Bookmarks("PartAwardsText").Range.Text = "Accepted components of your
Offer include"
End If

Needless to say, this doesn't work and any help would be greatly appreciated.

Thank you.
 
G

Graham Mayor

You need to read the value from the button/check box when you click the
command button to enter the values from the userform, and personaly I would
use a docvariable to store the result and place that with a docvariable field
e.g. something along the lines of

Option Explicit
Private oVars As Variables
Private Sub CommandButton1_Click()
Set oVars = ActiveDocument.Variables
If togPartAwardsText.Value = True Then
oVars("PartAwardsText").Value = _
"Accepted components of your Offer include"
Else
oVars("PartAwardsText").Value = " "
End If
ActiveDocument.Fields.Update
Unload Me
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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