From: LisaM on
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.
From: Graham Mayor on
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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



"LisaM" wrote:

> 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.