Which Word group do I use to post this question?

P

Pat Beck

I don't want to bother the wrong group, so can you tell me which Word
newsgroup would be best to post a question about trying to create a drop
down list in a document that would change another paragraph elsewhere in the
document based on the choice made. (Sort of like a VLOOKUP in Excel.) But it
has to be Word and cannot refer to external data.

I have a strategy I'm unsuccessfully pursuing <g> and will post the details
in the proper group you direct me to. I'm pretty fair with coding in Excel
but am lost in Word. I'm wasting a lot of time and need help.

Thank you,
Pat
 
P

Pat Beck

Here's my situation, which is pretty simple, but I'm really spelling it out
here:

I need a document with a drop down field where a user will choose from
Product1, Product2, Product3, or Product4. In a new paragraph below the
field is the word "Description". Below that word, a corresponding paragraph
of text needs to appear - according to the product chosen. (A UserForm is
not preferred.)

Farther into the document, the four possible descriptions can exist as four
separate paragraphs. Each having its text bookmarked as Desc1, Desc2, Desc3,
or Desc4. The field choice, "Product1" correlates to "Descr1" and so on.

So, if the user chooses "Product3" in the drop down field, the text from
bookmark "Descr3" appears below "Description".

Here's the strategy I was trying but cannot completely create. Maybe it's
impossible:

- A drop down field ("ProductChoice") is created with items: Product1,
Product2, Product3, Product4.
- Four paragraphs are typed, being the four descriptions, farther into the
document.
- Each description paragraph is bookmarked as "Descr1", "Descr2", "Descr3",
or "Descr4" - respective to the product numbers in the drop down field.
- Below the drop down field the word "Description:" is entered.
- Below "Description" a cross-reference is inserted (Bookmark type /
Reference to Bookmark Text) and set to the bookmark "Descr1".
- Upon exit of the product number drop down field, the cross-reference
resets its bookmark portion of code to what was chosen in the product number
drop down field.

I'm more of an Excel person and can do this quickly there, even create
UserForms. But this is restricted to Word and a UserForm is not preferred by
the high sheriffs. Also, it cannot be linked to external data. It's
preferred to be an in-document drop down arrow that pulls text from within
the document.

Thanks,
Pat Beck
 
P

Pat Beck

Thanks for the information. Unfortunately, a UserForm is not preferred. In
Word, is a UserForm the only way to cause text to appear based on an
in-document listbox?

(Please see reply to Peter Jamieson for details.)

Oh, I'm using version 2002 if that's important.

Thanks,
Pat Beck
 
G

Graham Mayor

Pat said:
Here's my situation, which is pretty simple, but I'm really spelling
it out here:

That helps :)
I need a document with a drop down field where a user will choose from
Product1, Product2, Product3, or Product4. In a new paragraph below
the field is the word "Description". Below that word, a corresponding
paragraph of text needs to appear - according to the product chosen.
(A UserForm is not preferred.)

The user form would be the best bet, but if you want to try another route,
you would need to create a protected form with form fields. You can insert a
drop down form field with up to 25 entries. By default the drop down field
will be bookmarked Dropdown1 - though you can change this if required.
Farther into the document, the four possible descriptions can exist
as four separate paragraphs. Each having its text bookmarked as
Desc1, Desc2, Desc3, or Desc4. The field choice, "Product1"
correlates to "Descr1" and so on.

Here you would use conditional fields on the same line. You can either
insert the text directly from the conditional field or use it to insert an
autotext entry using an AUTOTEXT field or a file using an INCLUDETEXT field.
eg {IF {REF Dropdown1} = "Product 1" "Insert the text for description 1"}{IF
{Ref Dropdown1} = "Product 2" "Insert the text description 2"} etc
So, if the user chooses "Product3" in the drop down field, the text
from bookmark "Descr3" appears below "Description".

See above - you can use the conditional fields as many times as you need
then to perform whatever insertion task you require.
*NOTE - You must check the 'Calculate on exit' box in the drop down field
properties.*
Here's the strategy I was trying but cannot completely create. Maybe
it's impossible:

- A drop down field ("ProductChoice") is created with items: Product1,
Product2, Product3, Product4.
- Four paragraphs are typed, being the four descriptions, farther
into the document.
- Each description paragraph is bookmarked as "Descr1", "Descr2",
"Descr3", or "Descr4" - respective to the product numbers in the drop
down field.
- Below the drop down field the word "Description:" is entered.
- Below "Description" a cross-reference is inserted (Bookmark type /
Reference to Bookmark Text) and set to the bookmark "Descr1".
- Upon exit of the product number drop down field, the cross-reference
resets its bookmark portion of code to what was chosen in the product
number drop down field.

I'm more of an Excel person and can do this quickly there, even create
UserForms. But this is restricted to Word and a UserForm is not
preferred by the high sheriffs. Also, it cannot be linked to external
data. It's preferred to be an in-document drop down arrow that pulls
text from within the document.

Thanks,
Pat Beck


--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail (e-mail address removed)
Web site www.gmayor.dsl.pipex.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 
P

Pat Beck

Thanks, Graham. I've got it partially working. I'd like to paste the code
here and discuss it, but I don't know how to copy the code. I toggled to
field code, but it won't let me copy it. Only the code result pastes. Can
this be copied?



Pat Beck
 
P

Peter Jamieson

Unfortunately the {} are special characters so you can only really paste
succesfully into another Word document. But the following small VBA macro
will convert the fields in the current selection to a format you can paste
from either the IMmediate window of the VB Editor or the document creatred
by the macro. It's crude, but it will probably do most of what you need. I
expect other MVPs have got much better macros than this.

Sub spelloutfieldcodes()
Dim r As Range
Dim i As Long
Dim s As String
Dim a As Long
Dim sfc As Boolean
Dim sht As Boolean
sfc = ActiveDocument.ActiveWindow.View.ShowFieldCodes
ActiveDocument.ActiveWindow.View.ShowFieldCodes = True
sht = ActiveDocument.ActiveWindow.View.ShowHiddenText
ActiveDocument.ActiveWindow.View.ShowHiddenText = True
Set r = Selection.Range
s = ""
For i = 1 To Len(r.Text)
a = AscW(Mid(r.Text, i, 1))
Select Case a
Case 1: s = s & "<inline graphic>"
Case 9: s = s & "<tab>"
Case 13: s = s & "¶" & ChrW(13)
Case 19: s = s & "{"
Case 21: s = s & "}"
Case Else
s = s & ChrW(a)
End Select
Next
Debug.Print s
Set r = Nothing
ActiveDocument.ActiveWindow.View.ShowFieldCodes = sfc
ActiveDocument.ActiveWindow.View.ShowHiddenText = sht

Dim d As Document
Set d = Documents.Add
d.Content.InsertAfter Text:=s
Set d = Nothing
End Sub
 
P

Pat Beck

Graham, thanks for confirming I can't force an exit. I'll stop trying. <g>

I think what you gave me so far will work. The mock up seems to please the
high sheriffs, so I'll leave it at that. But I'll check back if I have other
questions. You've been a great help. Thanks again.

Patricia Beck
 

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