Hey, could you post an example in a .doc file, i dont need to do this, but i dont know how to program in VB.
fumei via OfficeKB.com wrote:
Re: Drop Down List to display graphic image file
26-Sep-07
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
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.
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200709/1
Previous Posts In This Thread:
Drop Down List to display graphic image file
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
Re: Drop Down List to display graphic image file
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.
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
laknight wrote:
Jay,Thanks for the link.
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.
:
Re: Drop Down List to display graphic image file
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
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.
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200709/1
Thanks for responding.
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).
:
There are so many moving parts to this setup that it's hard to tell which
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.
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
laknight wrote:
Hmmmm. I got it to work with images.
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?
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200709/1
RE: Drop Down List to display graphic image file
Hey man, can u post a example? I need to do this, but i have no idea how to do it with VB.
By example I mean something in an actual .doc file.
Submitted via EggHeadCafe - Software Developer Portal of Choice
Toward Viable CAPTCHA Alternatives
http://www.eggheadcafe.com/tutorial...c-a34cd08623e8/toward-viable-captcha-alt.aspx