Consulting

Results 1 to 4 of 4

Thread: Solved: LoadPicture Function in Powerpoint Userform

  1. #1

    Solved: LoadPicture Function in Powerpoint Userform

    Hi. I've created a very simple userform that only contains an image (image1) and a checkbox (checkbox1). I want to load and unload a picture via a checkbox. I wrote the following code, which works fine if I just click the checkbox on and off.

    However, if I click on the image box at any point, the checkbox no longer works (i.e. the image stays in the state it was previously and won't change when I click the checkbox anymore).

    I'm sure this is something super-simple I'm missing, but any help would be appreciated. My code is below...

    [vba]
    Private Sub CheckBox1_Click()

    If CheckBox1.Value = True Then
    UserForm1.Image1.Picture = LoadPicture("D:\Storage\Test.jpg")
    Else
    UserForm1.Image1.Picture = LoadPicture("")
    End If

    End Sub
    [/vba]

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Not sure why but try setting the enabled property of Image1 to False
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    MS Excel MVP VBAX Mentor Andy Pope's Avatar
    Joined
    May 2004
    Location
    Essex, England
    Posts
    344
    Location
    Try,

    Private Sub CheckBox1_Click() 
         
        If CheckBox1.Value = True Then 
            UserForm1.Image1.Picture = LoadPicture("D:\Storage\Test.jpg") 
        Else 
            UserForm1.Image1.Picture = LoadPicture("") 
        End If 
        UserForm1.Repaint 
    End Sub
    Cheers
    Andy

  4. #4
    Perfect - thanks guys. Andy, I've implemented your change and it works fantastically. (No idea why VBA needs this, but the main thing is it's fixed!). Thanks for your help - much appreciated!

Posting Permissions

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