Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.newusers
William Millspaugh
 
Posts: n/a
Default where to insert code in dropdown box?

I have 2 templates, one of them has some dropdowns with a yes or no
selection. What I need to know is where does this code go... I need this
dropdown to automatically bring up another document if the answer is
"yes".......

If ActiveDocument.FormFields("DropDown1").result = "Yes" Then
Documents.Add ("TemplateName.dot")
End If

I know it needs to relate to the dropdown box in the doc. Could someone
explain...

Thanks alot. Bill


  #2   Report Post  
Posted to microsoft.public.word.newusers
Jay Freedman
 
Posts: n/a
Default where to insert code in dropdown box?

Hi Bill,

General instructions are at http://www.gmayor.com/installing_macro.htm, but
you need a bit more than that.

In the template that contains the dropdown, open the VBA editor and type
this line:

Sub ExitDropdown1()

When you press Enter at the end of the line, Word will automatically supply
the line

End Sub

Between those two lines, paste the three lines you showed.

Also make sure the name "DropDown1" matches the bookmark name shown in the
dropdown's Properties dialog, and that "TemplateName.dot" matches the name
of the template you want to base the new document on. Change them to match
if necessary. Save the template and close the VBA editor.

Back in the template, open the dropdown's Properties dialog. Pull down the
Exit list and select ExitDropdown1. This sets the connection so that the
macro runs when the cursor leaves the dropdown.

Save the template again, and create a new document on it to test the
dropdown.

One other minor bit: The equality test in the macro is case-sensitive. In
other words, the choice in the dropdown that makes the new document appear
*must* be "Yes" and not "YES" or "yes". There's a way to change the macro's
behavior if necessary, but it's easier to just make sure the dropdown has
the right case.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

William Millspaugh wrote:
I have 2 templates, one of them has some dropdowns with a yes or no
selection. What I need to know is where does this code go... I need
this dropdown to automatically bring up another document if the
answer is "yes".......

If ActiveDocument.FormFields("DropDown1").result = "Yes" Then
Documents.Add ("TemplateName.dot")
End If

I know it needs to relate to the dropdown box in the doc. Could
someone explain...

Thanks alot. Bill



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I change the HTML code back to WYSIWYG? miggols99 Microsoft Word Help 3 October 30th 08 05:46 AM
The insert command has stopped working in all my Office productsd CWhit Microsoft Word Help 16 April 15th 06 05:13 PM
Mail Merge Field window should remain open to insert multiple fiel Steinway60 Mailmerge 1 July 20th 05 04:08 PM
Insert a file into a merge field kim Mailmerge 1 July 18th 05 05:13 PM
UPC BAR CODE davek Microsoft Word Help 4 March 22nd 05 11:16 PM


All times are GMT +1. The time now is 07:13 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"