Word - AutoFill Text from Dropdown
Asked By Dax Arroway
08-Jan-10 02:56 PM
I have a 5x5 table in which the first column has drop downs with choices
Level 1 through Level 5. The columns have descriptive text in them which
should change depending upon the users choices in the dropdowns. Is there a
way of doing this?
For instance, if someone opened this form and selected Level II from the
dropdown menu, the cells across the row would fill with predetermined text
that matched descriptions for Level II. If they changed it to Level III, the
descriptions would follow, and so on and so forth.
Does anyone know how to do this or know where a webpost is or a webpage
which describes the process. (And excuse me if this is all ready discussed.
I searched but could not find anything.)
Thanks so much in advance!
--Dax
--
I would give my left hand to be ambidextrous!
Windows XP
(1)
Excel
(1)
Word
(1)
Selection.FormFields
(1)
VBA
(1)
MacrosVBA
(1)
Range.FormFields
(1)
FAQs
(1)
Doug Robbins - Word MVP replied to Dax Arroway

Here is one way of doing it.
Assuming that you wanted the same result in all of the cells 2 through 5 of
a row, you would run a macro containing the following code on exit from the
dropdown formfield in each cell of the first column:
Dim ddresult As String
ddresult = Selection.FormFields(1).result
Select Case ddresult
Case "Level 1"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).result = "Result
for Level 1"
Next i
Case "Level 2"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).result = "Result
for Level 2"
Next i
Case "Level 3"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).result = "Result
for Level 3"
Next i
Case "Level 4"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).result = "Result
for Level 4"
Next i
Case Else
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).result = "Result
for Level 5"
Next i
End Select
If you want something different in each cell in the row, then in place of
the constructions like
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).result = "Result
for Level 1"
Next i
you are going to need
Selection.Rows(1).Cells(2).Range.FormFields(1).result = "Result for
Level 1 in Column 2"
Selection.Rows(1).Cells(3).Range.FormFields(1).result = "Result for
Level 1 in Column 3"
Selection.Rows(1).Cells(4).Range.FormFields(1).result = "Result for
Level 1 in Column 4"
Selection.Rows(1).Cells(5).Range.FormFields(1).result = "Result for
Level 1 in Column 5"
If you do not want the user to be able to edit the result in columns 2
through 5, you can uncheck the Fill-in enabled box for the formfields in
those cells.
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Dax Arroway replied to Dax Arroway
Sort of like an IF, THEN statement. IF cell A1 has Level 1 selected from the
dropdown, then B1 is <Level 1 B text>, C1 is <Level 1 C text>, D1 is <Level 1
D text>. Or if A1 is Level 2 selected, then B1 is <Level 2 B text>, C1 is
could do this? Seems simple enough. I have actually figure out how to do this
with Excel but I do not want an inserted excel document into my Word document.
I'd rather it only be a Word document with a Word Table. I can also do this
with HTML but again, I'd prefer this only be a Word doc. Anyone???
--
I would give my left hand to be ambidextrous!
Doug Robbins - Word MVP replied to Dax Arroway
See my response to your original post.
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Dax Arroway replied to Doug Robbins - Word MVP

Hi Doug et al,
Thank you and yes that is perfect. The cells will be filled with different
information across the table so I will use the latter example and cut and paste
the text into the macro. I am also using "Level 1" through "Level 5" as the
dropdown choices for each cell A1:A5, however, they are unique. So there is
differenty "types" of questions associated with the levels. In other words I
need different titles so I get different results. I am guessing I could
simply put Case "A1Level 1", Case "A2Level 1" through out the code to obtain
these? Or is there a simpler way?
The other part that is eluding me is where this should go, how I should put
it into the document, and how to get the macro to run from the dropdown.
I am guessing I create a new macro, give it a name, which then opens the VBA
Editor and I insert the code into the box. Is that right? It does not seem
to work. I am obviously missing an important fundimental part. Should I be
inserting bookmarks into the cells or something?
Can someone describe the steps or is there an idiot's guide to macros
someplace? I am using Word03 on an WinXP machine if that helps.
Thanks again,
--Dax
-------------------------------------
I would give my left hand to be ambidextrous!
Doug Robbins - Word MVP replied to Dax Arroway
See the article "What do I do with macros sent to me by other newsgroup
readers to help me out???? at:
http://www.word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm
In the properties dialog box for the form field, you need to select that
macro to be run on exit from the field.
--
Hope this helps,
Doug Robbins - Word MVP
Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
Dax Arroway replied to Doug Robbins - Word MVP

Website's currently down but I think I am doing this right. Sorry for the
remedialness of this post but just to make sure please let me walk through my
steps.
Create word document and save.
Go to Tools\Macros\Macros, enter PCC for Macro Name, leave All active
templ...click Create.
VBA opens. Cut and paste code into macro. Close VBA editor.
Back in Word, Insert Table, 5 cells by 5 cells.
In first cell (A1) create dropdown menu giving 5 entries Level 1 throug
Level 5
Select PCC in dropdown of Macros to run on Exit. Leave dropdown enabled and
Calculate on exit unchecked. Bookmark default is Dropdown1, leave that.
Go to next cell down (A2) follow same procedue as A1, leave default bookmark
as Dropdown2.
Continue through A5. Lock document. Save.
At this point I am thinking I should be done and it should work. I drop down
the first dropdown and select a level, tab to next dropdown, and I get a MSVB
Run-time error '5941': The requested member of the collection does not exist.
Clicking Debug opens the VBA Editor which shows this highlighted code under
the selection I'd chosen in the dropdown. This code is:
Selection.Rows(1).Cells(i).Range.FormFields(1).Result = "Result for Level 3"
At this point I am stuck. From what I know of Macros and how to call and run
them I am doing everything right. What am I missing?
When the website comes back up I will reveiw the remedial Macro stuff but I am
wondering if its something else maybe???
--Dax
--
I would give my left hand to be ambidextrous!
Doug Robbins - Word MVP replied to Dax Arroway
The macro was written on the assumption that the formfields in columns 2
through 5 would be textinput type formfields
--
Hope this helps,
Doug Robbins - Word MVP
Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
Error &H80004005 Word Using Windows XP, EXCEL Office 2003. Each time I open an EXCEL workbook, I get the MICROSOFT VISUAL BASIC system error '&H80004005 (-2147467259) unspecified error' message. I message 'Compile error in hidden module: This Workbook'. This happens each time I open an EXCEL file whether it is a new one or not. Can anyone help me get rid of this, please? Thanks Yendorian Word VBA Discussions Windows XP (1) Office 2003 (1) Excel (1) Word (1) Yendorian (1) F1E289A586A6 (1) Times (1) Euro (1) It would be better
Word and Excel cannot open files - application hangs Word I am experiencing a problem I do not understand. This applies to Word 2007 and Excel 2007, running on Windows XP. windows and Office are up-to-date, with all security patches applied. With Word Open, If No dialog box, nothing - just an hourglass that waits. I have the same problem with Excel 2007. However, If I use Windows Explorer to find a file, and double click on the filename with Word not open resolve this issue or do I need to reinstall Office? - -Dan Word Application Errors Discussions XP (1) Excel (1) DanDanA (1) MSWord (1) MVP (1) FB (1) Office (1) Problem (1
Excel tables in Windows Vista Word I've used many Word files with linked Excel tables (office 2003)in Windows XP. My new computor with Vista give me problems with the Excel tables. If I open an old file and edit the table, the table changes in off rows at the bottom. This is very frustrating. Can anyone help? Word Tables Discussions Windows XP (1) Office System (1) Windows Vista (1) Office 2003 (1) Office 2007 (1) Excel (1
word 2007 will not open after migrating Word i just migrated everything from my old XP / windows 2003 laptop to new XP / windows 2007 laptop. word 2007 worked just fine before the migration - now it will not open. excel 2007 works fine, and outlook 2007 works ok (it hangs for about 5 minutes after to force quit. word 2003 opens OK. thanks for any help. Word Application Errors Discussions XP (1) FAQs (1) AppErrors (1) Outlook (1) Windows (1) Have you installed a printer driver and set as the Windows Default? - - Terry Farrell - MSWord MVP i would have guessed that the printer drivers were migrated
Word 97 error when printing. Problem does not occur when using a different Windows XP Profile Word Update: I tried creating a new Windows XP profile on the same computer that has the Word 97 printing glitch (Word crashes). The when using the new profile. I assume this must mean the problem is somewhere in Windows rather than with Word, yet all other apps print fine. Any idea where to look in Windows to correct this problem? FULL DESCRIPTION BELOW: Word 97 Winword.exe Application Error when printing this problem just started happening. It has SR-R and other patches installed running under Windows XP SR2. I have other machines setup exactly the same way, and none of them have