Consulting

Results 1 to 3 of 3

Thread: Inserting an image based on the option choosen

  1. #1

    Inserting an image based on the option choosen

    Hi, I've a VBA form which has got 3 radio buttons to choose an option, say "A", "B", "C". When I choose option "A", I want image "1.jpg" to be displayed in the form. If I choose option "B", I want "2.jpg" & so on. The images are stored in a network drive. I tried creating the radio buttons & I get the return value of which option is choosen. But, I got stuck in displaying the images which change dynamically when changing the options via radio buttons. I attach the file for ref. Appreciate your help!
    Attached Files Attached Files

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try
    [vba]Private Sub OptionButton1_Click()
    Image1.Picture = LoadPicture("C:\AAA\pic1.jpg")
    End Sub

    'etc.
    [/vba]

    Alternatively, add three images hard coded in the userform and switch between them

    [VBA]Private Sub OptionButton1_Click()
    Image1.Visible = True
    Image2.Visible = False
    Image3.Visible = False
    End Sub

    'etc.
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3

    Smile

    Thank you so much! I like option1 of your suggestion. Thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •