G
Greg Maxey
The other day there was a question here about providing a dropdown menu in a
form where a user could select from a graphic vice a text item. I suggested
that perhaps a userform with picture controls would work. I tested this
this morning. I found a few simply road sign .gif images and saved them on
my desktop
Using Word2003. I added a macro button to the form to call the userform and
a bookmark to display the graphic that the user selected. In the userform I
created four picture controls and added a road sign image to each one. The
code in the userform is as follows:
Option Explicit
Private Sub Image1_Click()
MsgBox "Correct. This is an advisory road sign"
InsertPic "AdvisorySpeed.gif"
Me.Hide
End Sub
Private Sub Image2_Click()
MsgBox "Incorrect. This is a regulatory road sign"
InsertPic "DoNotEnter.gif"
Me.Hide
End Sub
Private Sub Image3_Click()
MsgBox "Incorrect. This is a regulatory road sign"
InsertPic "NoTurn.gif"
Me.Hide
End Sub
Private Sub Image4_Click()
MsgBox "Incorrect. This is a regulatory road sign"
InsertPic "OneWay.gif"
Me.Hide
End Sub
Sub InsertPic(ByRef pStr As String)
Dim oRng As Word.Range
Set oRng = ActiveDocument.Bookmarks("bmPPH").Range
oRng.Text = " "
oRng.InlineShapes.AddPicture FileName:= _
"C:\Documents and Settings\Maxey\Desktop\" & pStr, LinkToFile:=False, _
SaveWithDocument:=True
ActiveDocument.Bookmarks.Add "bmPPH", oRng
End Sub
This seems to work quite nicely, but the problem that I see is its
exportability to other users. It won't work unless other users have the
same images on their desktops. I am looking for suggestions that would make
this form exportable to other users. I thought about using AutoText but
then I would have to send the form and its template to other users. Another
idea I had was to insert all four images in the document and then use the
PictureFormat.Brightness attribute to show/hide the selected image in the
document. This seems clunky as I haven't sorted out how to make the
selected image appear in the right spot. I know that with Word2007 I could
put the images in the documetns OpenXML Format File datastore \images folder
and use some code to extract them to a temporary folder on then users
desktop, but I am looking for something that would work with Word2003.
Any ideas? Thanks.
form where a user could select from a graphic vice a text item. I suggested
that perhaps a userform with picture controls would work. I tested this
this morning. I found a few simply road sign .gif images and saved them on
my desktop
Using Word2003. I added a macro button to the form to call the userform and
a bookmark to display the graphic that the user selected. In the userform I
created four picture controls and added a road sign image to each one. The
code in the userform is as follows:
Option Explicit
Private Sub Image1_Click()
MsgBox "Correct. This is an advisory road sign"
InsertPic "AdvisorySpeed.gif"
Me.Hide
End Sub
Private Sub Image2_Click()
MsgBox "Incorrect. This is a regulatory road sign"
InsertPic "DoNotEnter.gif"
Me.Hide
End Sub
Private Sub Image3_Click()
MsgBox "Incorrect. This is a regulatory road sign"
InsertPic "NoTurn.gif"
Me.Hide
End Sub
Private Sub Image4_Click()
MsgBox "Incorrect. This is a regulatory road sign"
InsertPic "OneWay.gif"
Me.Hide
End Sub
Sub InsertPic(ByRef pStr As String)
Dim oRng As Word.Range
Set oRng = ActiveDocument.Bookmarks("bmPPH").Range
oRng.Text = " "
oRng.InlineShapes.AddPicture FileName:= _
"C:\Documents and Settings\Maxey\Desktop\" & pStr, LinkToFile:=False, _
SaveWithDocument:=True
ActiveDocument.Bookmarks.Add "bmPPH", oRng
End Sub
This seems to work quite nicely, but the problem that I see is its
exportability to other users. It won't work unless other users have the
same images on their desktops. I am looking for suggestions that would make
this form exportable to other users. I thought about using AutoText but
then I would have to send the form and its template to other users. Another
idea I had was to insert all four images in the document and then use the
PictureFormat.Brightness attribute to show/hide the selected image in the
document. This seems clunky as I haven't sorted out how to make the
selected image appear in the right spot. I know that with Word2007 I could
put the images in the documetns OpenXML Format File datastore \images folder
and use some code to extract them to a temporary folder on then users
desktop, but I am looking for something that would work with Word2003.
Any ideas? Thanks.