Choice in DD field toggles a Schedule on/off

C

C''''est_moi

Word 2003. Password Protected Form. DropDown
Not quite sure if what I envision is even feasible.

Have a Schedule at the end of a contract. I have a DD in the body of the
document (two options: "below" or "Schedule A"). User to enter his
description "below" (in open fields or unprotected areas) or (if too long) in
"Schedule A" (in 2 different unprotected areas). Would like the Schedule to
"toggle" depending on user choice. User chooses "below": schedule disappear;
user chooses "schedule A": schedule stays.

Schedule has styles, headings, cross-referenced text and part of Schedule
(where description to be entered) must be remain unprotected.

I have tried with Graham "OnExitDD1()" (with autotext entry) which works to
a certain extent by keeping formatting, c/r and all (and this command came
very handy for another situation I might add). However, If I breakpage (in
style) before heading of Schedule (b/c I want it on a page by itself of
course) command tells me there is too much text or something along these
lines.

For now, I bookmarked Schedule. When user chooses "below", Schedule
disappears. I then disable DD field (b/c if user changes his mind and
rechooses Schedule A, it is unavailable since it was removed when he first
exited the DD). Works fine but I am racking my brain for some sort of a
"toggling" device.

Thx for your help/ideas. A bit of a warning: I am a neophyte in this VBA
programming (but eager to learn). So thx for your patience and understanding.
 
G

Gordon Bentley-Mix

Hmm... I'm not sure how to go about this using an OnExit macro with a
formfield, but if I were trying to do it based on input from a UserForm, I'd
probably write code to show / hide the content of a couple of bookmarks by
toggling the .Hidden property of the Font associated with the bookmark's
range. If it was just a matter of swapping content in and out based on the
value selected, then I'd use a couple of AutoText entries, but that won't
really work in this case because "below" and "Schedule A" refer to different
areas in the document.

In fact, I actually do this a lot in almost all of the templates I've
developed for one of my clients - to the point that I wrote a couple of
"generic" procedures that accept arguments to make it easier. They look
something like this:

Public Sub ShowBookmarkRange(BkmkName As String)
If ActiveDocument.Bookmarks.Exists(BkmkName) Then
ActiveDocument.Bookmarks(BkmkName).Range.Font.Hidden = False
End If
End Sub

Public Sub HideBookmarkRange(BkmkName As String)
If ActiveDocument.Bookmarks.Exists(BkmkName) Then
ActiveDocument.Bookmarks(BkmkName).Range.Font.Hidden = True
End If
End Sub

The call in the main procedure would then look like this:

If cboDescriptionLocation.Value = "below" Then
ShowBookmarkRange "below"
HideBookmarkRange "Schedule A"
ElseIf cboDescriptionLocation.Value = "Schedule A" Then
ShowBookmarkRange "Schedule A"
HideBookmarkRange "below"
End If

(Actually, I'd evaluate the .ListIndex and probably use a Select Case
statement, but this should give you an idea...)

HTH
--
Cheers!

Gordon Bentley-Mix
Word MVP

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
C

C''''est_moi

Thank you very much for your thoughts/help/time Gordon. I am so relieved to
be able to find support from so knowledgable people with such rapidity. I
have been wrestling with that Schedule situation for some months now, trying
to come up with a solution different from what I found, even though it works
but not to my entire satisfaction. I will run some tests with your codes. I
had tried a macro with "hidden" last Spring (and also with color change to
white) but on the computer of some users, it did not work. Everything
remained visible on screen (although it had worked perfectly fine on my
computer, both on screen and on paper once printed). I had thus never pursued
this avenue. In reading your codes, I see that they would probably solve my
problem.

Thx a million and have a nice day.
Carmen
 
G

Gordon Bentley-Mix

Carmen,

In re: "...on the computer of some users, it did not work. Everything
remained visible on screen (although it had worked perfectly fine on my
computer, both on screen and on paper once printed)."

Could it be that those users had their computer (specifically Word)
configured to show and/or print hidden text? In this case, the "hidden"
content will still be visible and may print - although hiding and not
printing hidden content is the default setting. Is the "hidden" content
displayed with a dotted purple line under it? If so then it's definitely
formatted as hidden but is still visible because of the settings in Word.

To get around this, I usually include code to set the option to hide the
hidden content, but I don't really like to do this as it's making a change
to a "global" setting without warning the user. However, I know my user base
well enough to recognise that 99% of the time they won't be any the wiser -
and the other 1% will know enough to change it back without too much
trouble. ;-P
--
Cheers!

Gordon Bentley-Mix
Word MVP

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
C

C''''est_moi

Complicated situation. I create those forms to be used on a number of
computers in a number of provinces with users on Word2000-2002 and/or 2003
who don't know the first thing about Word. Also, computers are regularly
"updated" either from here (Cda) or from the US directly which I was told by
IT affects Word settings!. Users often open forms through their desktop
(instead of opening Word first) which that in itself sometimes create
unforeseen situations. I had tried something last spring with the hide
function (both screen/print -- had the macro change settings in Tools) but
for some odd reason that I cannot investigate, it did not work with those
that I use as "ginea pigs" to test things. Needless to say that when I find
something does not work properly, I do not pursue the avenue and expand my
energies on something else since things always have to be done by last
week...!!! Thx so very much for your help Gordon. I cannot get over how nice
you are.
Carmen
 
G

Gordon Bentley-Mix

No worries Carmen. Glad to help. If there's anything else just ask.
--
Cheers!

Gordon Bentley-Mix
Word MVP

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 

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