From: Brenda on
Can you use a field to reference a selection made on a VBA form?

Scenario:
1. Word 2007
2. Deed Document (used as a template)
3. Depending on whether the Grantor is a person or company there are two
different Affidavits
4. I cannot use a .dot file because our Document Management Systems will
not open .dot files therefore cannot use AutoText

On my vba form there are option buttons - individual(s) or company.
Depending on the option you select, in the document I'd like: If you
selected the company option then use this affidavit but don't know how to
reference the PrecForm1.grantorcompany option button in Word's If field (if
it can be done at all).

Tks...Brenda
From: DaveLett on
Hi Brenda,
Yes and no.
When you run the form, you can save the value of your selection in a couple
of ways (add it as a custom document property or a document variable) and
then use a field to display that value. The following shows how to add it as
a document variable:

ActiveDocument.Variables.Add Name:="bCompany", Value:="False"

If you need to update the value, then you'll have to account for that. After
the variable is added to the document, then you can reference using a
DocVariable field. The following shows the text of that field using the above
example:

Docvariable “bCompany”

HTH,
Dave

"Brenda" wrote:

> Can you use a field to reference a selection made on a VBA form?
>
> Scenario:
> 1. Word 2007
> 2. Deed Document (used as a template)
> 3. Depending on whether the Grantor is a person or company there are two
> different Affidavits
> 4. I cannot use a .dot file because our Document Management Systems will
> not open .dot files therefore cannot use AutoText
>
> On my vba form there are option buttons - individual(s) or company.
> Depending on the option you select, in the document I'd like: If you
> selected the company option then use this affidavit but don't know how to
> reference the PrecForm1.grantorcompany option button in Word's If field (if
> it can be done at all).
>
> Tks...Brenda
From: Brenda on
Sorry Dave, I think I'm missing something:

In my vba form I have an option box called grantorsm and another one called
grantorc

In my document, I'd like to do:

{if grantorsm = True "This is the affidavit for a single male" "This is the
affidavit for a company"}

This works for me if I use fillin fields in my document but the option I'm
referring to is in a vba form. I want to avoid having to type the whole
affidavit in the vba window.

"DaveLett" wrote:

> Hi Brenda,
> Yes and no.
> When you run the form, you can save the value of your selection in a couple
> of ways (add it as a custom document property or a document variable) and
> then use a field to display that value. The following shows how to add it as
> a document variable:
>
> ActiveDocument.Variables.Add Name:="bCompany", Value:="False"
>
> If you need to update the value, then you'll have to account for that. After
> the variable is added to the document, then you can reference using a
> DocVariable field. The following shows the text of that field using the above
> example:
>
> Docvariable “bCompany”
>
> HTH,
> Dave
>
> "Brenda" wrote:
>
> > Can you use a field to reference a selection made on a VBA form?
> >
> > Scenario:
> > 1. Word 2007
> > 2. Deed Document (used as a template)
> > 3. Depending on whether the Grantor is a person or company there are two
> > different Affidavits
> > 4. I cannot use a .dot file because our Document Management Systems will
> > not open .dot files therefore cannot use AutoText
> >
> > On my vba form there are option buttons - individual(s) or company.
> > Depending on the option you select, in the document I'd like: If you
> > selected the company option then use this affidavit but don't know how to
> > reference the PrecForm1.grantorcompany option button in Word's If field (if
> > it can be done at all).
> >
> > Tks...Brenda
From: DaveLett on
Hi Brenda,
When you execute your userform, you need to store the values of the userform
with the document in some way. I chose Document Variables. If that's okay,
then you can execute something like the following when the user closes or
finishes the form:

ActiveDocument.Variables.Add Name:="grantorsm",
Value:=UserForm1.grantorsm.Value

In the document, then, you can create a nested field that looks something
like the following:

{ IF { DocVariable "grantorsm" } = True “This is the affidavit for a single
male” “This is the affidavit for a company” }

HTH,
Dave


"Brenda" wrote:

> Sorry Dave, I think I'm missing something:
>
> In my vba form I have an option box called grantorsm and another one called
> grantorc
>
> In my document, I'd like to do:
>
> {if grantorsm = True "This is the affidavit for a single male" "This is the
> affidavit for a company"}
>
> This works for me if I use fillin fields in my document but the option I'm
> referring to is in a vba form. I want to avoid having to type the whole
> affidavit in the vba window.
>
> "DaveLett" wrote:
>
> > Hi Brenda,
> > Yes and no.
> > When you run the form, you can save the value of your selection in a couple
> > of ways (add it as a custom document property or a document variable) and
> > then use a field to display that value. The following shows how to add it as
> > a document variable:
> >
> > ActiveDocument.Variables.Add Name:="bCompany", Value:="False"
> >
> > If you need to update the value, then you'll have to account for that. After
> > the variable is added to the document, then you can reference using a
> > DocVariable field. The following shows the text of that field using the above
> > example:
> >
> > Docvariable “bCompany”
> >
> > HTH,
> > Dave
> >
> > "Brenda" wrote:
> >
> > > Can you use a field to reference a selection made on a VBA form?
> > >
> > > Scenario:
> > > 1. Word 2007
> > > 2. Deed Document (used as a template)
> > > 3. Depending on whether the Grantor is a person or company there are two
> > > different Affidavits
> > > 4. I cannot use a .dot file because our Document Management Systems will
> > > not open .dot files therefore cannot use AutoText
> > >
> > > On my vba form there are option buttons - individual(s) or company.
> > > Depending on the option you select, in the document I'd like: If you
> > > selected the company option then use this affidavit but don't know how to
> > > reference the PrecForm1.grantorcompany option button in Word's If field (if
> > > it can be done at all).
> > >
> > > Tks...Brenda