• Image Control, changing image source

    Author
    Topic
    #474860

    Hi!

    I have a UserForm in Word 2003, and I have an image control on it. I’d like to change the image displayed in the control based on a combo box. The problem is that I can’t figure out what property to change of the image control. When you put a picture in an image control, you do it in the .Picture property, but apparently that can’t be done in VB code in Word? (in Access it’s soooo much easier :mad:)

    So there’s a whole bunch more properties of the image control that are revealed in the VB(A) editor, such as .ControlSource and .RowSource, but I can’t figure out what they’re for, but setting what image is displayed in the image control isn’t a function of any of them either…?

    Ultimately, my goal is to have a user pick a choice from a combo box, which will display certain things on the form, which will then populate into the Word document. I’ve got everything running fine (ie. all the text populates and inserts) except the image.

    Anyone got any suggestions or samples that might help?

    Thanks!

    Cecilia 🙂

    Viewing 1 reply thread
    Author
    Replies
    • #1267918

      Hi Cecilia,

      Not sure how to change the .Picture property via code, but a ‘cheat’ method that might be workable if you don’t have too many pictures is to create and name a separate picture control for each different picture. Then superimpose them all in the same place on the form. The code that responds to the combo box selection can set the relevant picture control to .Visible = True and all the others to .False.

      Alternatively you can create and load a picture for each control, and then in the IDE set its Left and Top properties so that it’s located off the form. And then use the combo box code to bring the picture control you need, to the correct Top and Left location.

      Gary

      • #1267921

        Thanks, Gary…that’s a nice “outside the box” solution. I’ll try it, but I think I have too many images (so far I’m up to 12, and possibly a few more than that), it’ll probably slow things down considerably.

    • #1267944

      Have you tried the method described in the help file?

      object.Picture = LoadPicture( pathname )

    Viewing 1 reply thread
    Reply To: Image Control, changing image source

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: