How can I set an automated form to show/hide a section?

G

Guest

Hi all, I'm working in Word 2003 making an automated form template (trying,
anyway). Under the first question, the user can select "new" or "existing"
from the drop-down field. When the user selects "existing," I want a section
to appear/show/drop/toggle (I'm not sure what the right verbiage is) that
will give them some options to choose from, i.e. "existing member already has
the following: (check boxes) a, b, c, d, e"...etc. If the user selects "new,"
I dont want this section to appear since it will not be applicable.

I'm brand-spanking new to the world of macros and VBE...please keep in mind
when explaining. Thanks in advance and I really appreciate any help you can
give.
 
J

Jay Freedman

Natalie said:
Hi all, I'm working in Word 2003 making an automated form template
(trying, anyway). Under the first question, the user can select "new"
or "existing" from the drop-down field. When the user selects
"existing," I want a section to appear/show/drop/toggle (I'm not sure
what the right verbiage is) that will give them some options to
choose from, i.e. "existing member already has the following: (check
boxes) a, b, c, d, e"...etc. If the user selects "new," I dont want
this section to appear since it will not be applicable.

I'm brand-spanking new to the world of macros and VBE...please keep
in mind when explaining. Thanks in advance and I really appreciate
any help you can give.

Have a look at MVP Greg Maxey's page at
http://gregmaxey.mvps.org/Toggle_Data_Display.htm, and follow the links
there for additional help. If you get part way through it and can't get
something to work, post here and describe the problem.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
G

Guest

What I want my form to do is if a formcheckbox is selected, then other
formcheckboxes are displayed, providing more options. if the formcheckbox is
not selected (or "x"ed), then the other formcheckboxes do not display.

I did read Greg Maxey's toggle data display, but i'm not sure how to write
the macro named showhide2 to make it do what i want. is there any way i can
do this without macros? maybe just field codes? i've purchased 2 books (Word
Bible and Step by Step Word) and cannot find what i'm looking for. I know i
probably sound like an idiot because, if not obvious, I don't really know
what I'm talking about...I just know what i wish my form would do.


please help me. i'm going on week 3 of trying to figure this thing
out...(hopefully that will get me some sympathy.)
 
J

Jay Freedman

Hi Natalie,

First, resign yourself to the fact that there's no simple way to do
this job in Word, and in particular there's no way to do it without
macros.

You can use the macros in Greg's page almost exactly as they are; just
copy and paste the corrected version from this message into a module
in the form's template (follow the link
http://www.gmayor.com/installing_macro.htm to get instructions if
necessary).

Option Explicit

Const pValue_1 = "Show"
Const pValue_2 = "Hide"

Sub CallShowHide()
ShowHide Selection.Bookmarks(1).Name
End Sub


Sub ShowHide(pVarName As String)
Dim pValue As String
On Error Resume Next
pValue = ActiveDocument.Variables(pVarName).Value
On Error GoTo 0
If pValue = "" Or pValue = pValue_2 Then
pValue = pValue_1
Else
pValue = pValue_2
End If
ActiveDocument.Variables(pVarName).Value = pValue
ActiveDocument.Fields.Update
End Sub

One thing Greg neglected to discuss in the article is that there are
bookmarks surrounding the MACROBUTTON fields. Those are the gray
square brackets that you see in his screen shots. The bookmark around
the field in the first row must be named ShowHide1 (the same as the
name in the DOCVARIABLE field in the same row), and the bookmark
around the field in the second row must be named ShowHide2. If you
have more toggles, just keep increasing the number on the end of the
names.

Another thing Greg didn't address explicitly is that his method can be
used in a protected form, and the AutoText entries can contain
checkbox formfields -- but the MACROBUTTON fields that toggle the
visibility of the AutoTexts have to contain characters that only look
like check boxes or buttons, not real checkbox formfields. You can
find appropriate characters in the Wingdings font.

If you want to see a real working template that uses this stuff, let
me know and I'll post one on a web page where you can download it.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
G

Guest

Hi Jay,

Thank you so much for responding to this and for your help and patience with
me. I would like to download a real working sample template of this if you
could share.

Again, you've been tremendously helpful and thanx for sharing your knowledge.
 
J

Jay Freedman

Hi Natalie,

You can download http://jay-freedman.info/toggle.dot (save it to disk and
put it in your Templates folder, then use File > New to make a new document
based on it).

The template has a lot of "moving parts" that all need to work together
based on the names you give to things:

- Each Macrobutton field is surrounded by a bookmark. The name of the
bookmark is 'ShowHide' followed by a unique number.

- For each macro button, there is an AutoText entry stored in the template,
containing the stuff that gets shown or hidden. The name of the AutoText
must include the same number as appears in the name of the corresponding
bookmark.

- For each macro button, there is an IF field containing nested DocVariable
and AutoText fields. The DocVariable field must contain the name of the
corresponding bookmark, including the number. The AutoText field must
contain the name of the AutoText entry.

- The IF field is surrounded by a bookmark whose name is 'Toggle' followed
by the same number as appears in the name of the corresponding bookmark.

As long as you follow those rules, you can add more sets of Macrobutton /
fields / bookmarks / AutoText entry without having to change anything in the
macros.

This template has forms protection turned on, only so the checkboxes within
the AutoText entries will operate. If your AutoText entries don't contain
form fields, and there aren't any form fields elsewhere in the document,
then you don't have to turn on forms protection.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
G

Guest

Hi Jay,

I don't know how to put into words my gratitude for all your help. Thank you
so very much for this. I cannot thank you enough for taking the time to do
this. Truly you are a very kind human being. I cannot praise and thank you
enough.

Sincerely,

Natalie W.
 
J

Jay Freedman

You're certainly welcome -- but you might want to wait until you've
tried to apply the scheme to your own template, and ask more questions
if some part of it isn't working right.
 
G

Guest

Ok, you predicted right--I've got one more question...

I know I cannot use the form checkbox in the macrobutton, but instead, can I
somehow set it up so that different characters/symbols are displayed when the
autotext is toggled on or off? For example, when the autotext is toggled to
hide, there's a box symbol, but when the autotext is toggled to show, the
symbol changes to a box with an x in it.
 
J

Jay Freedman

I was afraid you were going to ask that. :) The answer is yes, at the cost
of additional complexity. I've modified the template and reposted it in the
same place.

The additional parts are these:

- Add two more AutoText entries, one for the unchecked box (the £ character
formatted in Wingdings2 font) and one for the checked box (the S character,
also in Wingdings2). These are named boxblank and boxx.

- Replace the single character in the code of the Macrobutton fields with an
IF field, similar to the one that makes the text in the left column appear
and disappear. In this case, the boxx value appears when the docvariable is
set to "Show", and the boxblank value appears when it's set to "Hide".

- Add a line to the macro to update this new field.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
G

Guest

Hi Jay,

I just wanted to thank you again for everything. I cannot even begin to put
into words how grateful I am for your help. Without your direction (and your
template), I would have never figured this out. A million thanx, man.

Natalie W.
 
J

Jay Freedman

You're certainly welcome. Thanks like that are why I'm still here
after all these years.

Jay
 

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