+ Reply to Thread
Results 1 to 2 of 2

Programatically control picture property of Image control

Hybrid View

Brassman Programatically control... 05-23-2005, 10:12 AM
Brassman Figured it out... 05-24-2005, 10:11 AM
  1. #1
    Registered User
    Join Date
    08-18-2004
    Posts
    16

    Question Programatically control picture property of Image control

    I have a workbook with a table similar to this:
    Item No. | Description | PicPath
    ITEM1 | Item 1 description | C:/Images/a pic.jpg
    ITEM2 | Item 2 description | C:/Images/another pic.jpg


    On other sheets, I have vlookup functions calling records from the table. I also have image controls on those sheets, named the Item No.s (ITEM1, ITEM2).

    Is there a way I can programatically loop through those images and set the picture property? This is the basic idea of what I want to do, but it doesn't work. How do I need to fix it? Thank you very much.

    Sub GetPics()
    Dim c as Image
    
    For each c in Controls
    c.Picture = LoadPicture(Application.WorksheetFunction.VLookup(c.Name,Range("DataTable"),3,False))
    next c End Sub

  2. #2
    Registered User
    Join Date
    08-18-2004
    Posts
    16

    Lightbulb Figured it out...

    Figured out an answer to my own problem. I used the OLEobject and OLEobjects collection. Here's my code:

    Sub UpdatePics()
    Dim c As OLEObject
    For x = 1 To Worksheets.Count
        On Error GoTo ErrHand
        For Each c In Worksheets(x).OLEObjects
            With c
                    .Object.Picture = LoadPicture(Application.WorksheetFunction.VLookup(.Name, Range("TableData"), 5, False))
            End With
        Next c
    ErrHand:
    Next x
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1