Showing & Hiding info

M

Marco

In a user form I have a combo box that has a list of entities. I am wondering
if there is VBA code that I can write that shows a certain disclaimer on the
last page of a document based on the what entity was chosen in the combo box
on the user form.

Thanks
 
L

Leigh

You could do this with no VBA at all. Try this:

1. Create a new blank document.
2. Display the Forms toolbar (View, Toolbars, Forms).
3. Insert a DropDown form field, then double-click it to get to the
Drop Down Form Field Options dialog.
4. Add these entries to the dropdown: FooOne, FooTwo, FooThree.
5. In the Bookmark field, enter the name "ddFoo" (without the quotes)
6. Check the Calculate on Exit box.
7. Close the Drop Down Form Field Options dialog.
8. Hit the space bar a couple of times, and insert a text form field.
Its purpose is simply to give the user somewhere to tab to in order to
trigger the "Calculate on Exit".
9. Create three autotext entries named FooOne, FooTwo, and FooThree.
The names must match the values you entered in the Drop Down Form Field
earlier. The autotext *contents* would be whatever text you want to use
for the disclaimers.
10. Hit Enter a few times, then press Ctrl+F9 to insert an empty pair
of field markers. Inside the braces, type:

{ AUTOTEXT ddFoo \* MERGEFORMAT }

Note: do *not* type the braces shown here -- they are supplied by the
Ctrl+F9.
11. Inside the field braces, select the "ddFoo" characters with your
mouse. Press Ctrl+F9. This will surround ddFoo with another pair of
field braces. It should now look like this:

{ AUTOTEXT { ddFoo } \* MERGEFORMAT }

12. Click on the word AUTOTEXT inside the field braces, then press F9.
13. On the Forms toolbar, click the Padlock button to protect the form.
Choose an item from the dropdown. Press tab to move to the text box
(thereby activating the Calculate on Exit option you chose earlier).
14. Voila! The corresponding AutoText entry will appear in your
document. Play around and choose different drop-down choices. The
document updates automatically.

Note: if you do not tab out of the drop-down, you'll have to unprotect
the form, then click on your AutoText field (the thing you built in
steps 10 & 11), then press F9 to calculate it manually.
 
M

Marco

Hi Leigh,
Thanks for your suggestion. I couldn't use form fields as the protection
would allow my other vba code to run. Since my user form transferred the
variables to custom doc properties thru out the form, I wrote multiple if
statements:
{if{docproperty "entityname"} = "XYZ Co" "This is XYZ co disclaimer"
"{if{docproperty "entityname"} = "ZZZ Co" "This is ZZZ co disclaimer" ""}}
This seems to work great.
Marco
 

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