Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2007

Tip: Looking for answers? Try searching our database.

Drop Down List to display graphic image file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
laknight - 25 Sep 2007 18:30 GMT
Is there a way to create a drop down list with text choices so that when the
choice is made Word will display its corresponding graphic image instead of
the text choice? I've read a couple threads about auto text but not really
sure how to get it to work with a list of choices from a drop down list menu.

I did it once in Access, but I did not save the programming for it, or if I
did I can't find it. I don't even know if it's possible in Word.

Using XP SP2  Word 2003
Jay Freedman - 25 Sep 2007 20:58 GMT
See http://www.word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm. The AutoText
entries can be graphics, mixed text and graphics, or practically anything
else you can select within the body of a Word document. The AutoTextList
field creates the dropdown by showing the names of the AutoText entries;
this is not the same thing as a form dropdown.

Signature

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.

> Is there a way to create a drop down list with text choices so that
> when the choice is made Word will display its corresponding graphic
[quoted text clipped - 7 lines]
>
> Using XP SP2  Word 2003
laknight - 26 Sep 2007 16:10 GMT
Jay,

Thanks for the link. It works great for text, but I can't seem to get it to
work with images. I can see and view and insert the AutoText entry directly
from the AutoText menu in Word, but when I try to Right-Click on the field
code on the page I do not get my list of choices. Any idea why?  Thanks for
your help.

> See http://www.word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm. The AutoText
> entries can be graphics, mixed text and graphics, or practically anything
[quoted text clipped - 13 lines]
> >
> > Using XP SP2  Word 2003
Jay Freedman - 26 Sep 2007 18:45 GMT
There are so many moving parts to this setup that it's hard to tell which
specific point is interfering. Also, I'm trying to guess exactly what you're
doing. Here are some things to look at:

1. Are you sure that the pictures were in paragraphs formatted with the
correct style at the time you created the AutoText entries? (To check,
create an empty paragraph and format it with the style named in the
AutoTextList field. With the cursor in that paragraph, go to Insert >
AutoText. In the submenu, you should see only "AutoText...", "New", and the
names of the entries created in that style. If the names aren't there,
delete the entries and start again, using the correct style.)

2. Is the field collapsed to show just the default text, rather than the
"field code" with the braces? If the field code is still expanded, the field
doesn't operate; you get the field context menu instead.

3. Is the default text correctly spelled and capitalized? If the spelling
checker or grammar checker highlights that text, you'll get the
corresponding correction menu when you right-click instead of the list of
entries.

4. After you select a picture (once you can get that far), you can still
switch to another picture, but it's harder -- you have to put the cursor
immediately to the left of the picture (or to the left of the now-invisible
field if the picture is floating instead of in line with text) and
right-click. Otherwise you get the picture context menu or some other
right-click menu.

Signature

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.

> Jay,
>
[quoted text clipped - 29 lines]
>>>
>>> Using XP SP2  Word 2003
fumei - 26 Sep 2007 17:44 GMT
I do not really know what you mean by:

"so that when the choice is made Word will display its corresponding graphic
image instead of the text choice"

Huh?  That sounds like you want the image to display IN THE DROPDOWN.  No,
that is not possible.

Does it mean you want the dropdown to be REPLACED by the graphic?

The question come down to:  where do you want the image to be put?

Also, BTW...what KIND of dropdown?

Sub InsertMyImage()
Dim strImage As String
Dim r As Range

Set r = ActiveDocument.Bookmarks("InsertHere").Range

strImage = ActiveDocument.FormFields("Dropdown1").Result

ActiveDocument.AttachedTemplate.AutoTextEntries(strImage).Insert _
       Where:=r, _
     RichText:=True
End Sub

The above takes the result of a dropdown - whose items are the names of
AutoText entries - and puts the AutoText at the bookmark "InsertHere".

To make the AutoText entries, bring in the images, select them and then Tools
> AutoText > New.  Give them a name.  I used the generic sample images with
Windows (winter, sunset, blue hills).  I brought in each one, resized it the
way I wanted, selected them and made new AutoText named:  "winter", "sunset",
and "blue".  Deleted all the images.

Made dropdown - Dropdown1.  Put "winter", "sunset", and "blue" as the items.

Made a bookmark - "InsertHere"

Made Dropdown1 OnExit macro the above procedure InsertMyImage

Selecting a dropdown item and exiting will put the appropriate image after
the bookmark.  This is important.  It does NOT put the image inside the
bookmark range...no matter what Microsoft states about the range expanding to
do so.  It puts it AFTER.  So selecting another item from the dropdown will
ADD another image, NOT replace the previous image.
laknight - 26 Sep 2007 18:28 GMT
Thanks for responding. I do not want the graphic to display in the dropdown -
I just want the image to be displayed when the dropdown text item is chosen.

At first glance it seems like your solution would be good - but it the last
part of your info you mentioned that making another selection from the
dropdown would "add" another image next to it and not "replace" the previous
image. I would not be able to use it in the manner.

The AutoText function which Jay suggested in the previous message may be a
better option for me, but I can not get it to work with an image through the
field code by right-clicking on the page (even though it works fine when I
insert the AutoText entry directly from the Word AutoText menu).

> I do not really know what you mean by:
>
[quoted text clipped - 43 lines]
> do so.  It puts it AFTER.  So selecting another item from the dropdown will
> ADD another image, NOT replace the previous image.
fumei - 28 Sep 2007 03:33 GMT
Hmmmm.  I got it to work with images.  Are you sure you are using Style
correctly, and making sure about the paragraph marks - as mentioned in the
article?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.