Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Image Control automation error (Excel 2003)

    Hi all,

    I keep getting an automation error, I read the documentation on the error, but can not come up with the solution. What I am trying to do is check the value of textbox control on a form, then load a picture based on the value of textbox on an Image Control on the Form and on theWorksheet. The Picture file resides a on a server, that I have access.

    Is this a case where I need to set the imagecontrol.

    The Error is 440.

    Private Sub TXTmass_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Select Case TXTmass.Value
    Case "HENRY'S"
    Me.Image1.Picture = LoadPicture("P:PlatemakingMiscINVENTORY_GRAPHICSMA SS_IMPACT_GRAPHICSHENRYS.jpg")
    Sheet6.worksheetImage1.Picture = LoadPicture("P:PlatemakingMiscINVENTORY_GRAPHICSMA SS_IMPACT_GRAPHICSHENRYS.jpg")
    Case "HENRYS"

    Me.Image1.Picture = LoadPicture("P:PlatemakingMiscINVENTORY_GRAPHICSMA SS_IMPACT_GRAPHICSHENRYS.jpg")
    Sheet6.worksheetImage1.Picture = LoadPicture("P:PlatemakingMiscINVENTORY_GRAPHICSMA SS_IMPACT_GRAPHICSHENRYS.jpg")
    Case "TIGER DIRECT"

    Me.Image1.Picture = LoadPicture("P:PlatemakingMiscINVENTORY_GRAPHICSMA SS_IMPACT_GRAPHICSTIGER_DIRECT.jpg")
    Sheet6.worksheetImage1.Picture = LoadPicture("P:PlatemakingMiscINVENTORY_GRAPHICSMA SS_IMPACT_GRAPHICSTIGER_DIRECT.jpg")
    Case "MDG"

    Me.Image1.Picture = LoadPicture("P:PlatemakingMiscINVENTORY_GRAPHICSMA SS_IMPACT_GRAPHICSMDG.jpg")
    Sheet6.worksheetImage1.Picture = LoadPicture("P:PlatemakingMiscINVENTORY_GRAPHICSMA SS_IMPACT_GRAPHICSMDG.jpg")
    Case "TORONTO STAR MASS IMPACT"

    Me.Image1.Picture = LoadPicture("P:PlatemakingMiscINVENTORY_GRAPHICSMA SS_IMPACT_GRAPHICSTORONTOSTARBANNER.jpg")
    Case "Toronto Star Mass Impact"

    Me.Image1.Picture = LoadPicture("P:PlatemakingMiscINVENTORY_GRAPHICSMA SS_IMPACT_GRAPHICSTORONTOSTARBANNER.jpg")
    Me.Image1.Picture = LoadPicture("P:PlatemakingMiscINVENTORY_GRAPHICSMA SS_IMPACT_GRAPHICSTORONTOSTARBANNER.jpg")

    End Select

    End Sub
    from this code can some one steer me in the right direction?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Image Control automation error (Excel 2003)

    On which line do you get the error?

  3. #3
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Image Control automation error (Excel 2003)

    Thanks Hans,

    I am getting the Error on CASE "TIGER DIRECT", and Also on case "TORONTO STAR MASS IMPACT"

    It does work for the other cases.

    Thanks,
    Darryl.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Image Control automation error (Excel 2003)

    That would seem to indicate that either the file name for those cases is incorrect, or that there is a problem with the.jpg files for those cases.

    BTW, your code seems inconsistent. Why is Sheet6.worksheetImage1.Picture not set for "TORONTO STAR MASS IMPACT"? And why do you set the same image twice for "Toronto Star Mass Impact"?

  5. #5
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Image Control automation error (Excel 2003)

    Thank you Hans,

    I have been messing with the code that's why it was a mess. The problem was with the jpg, I don't know why, but for some reason the files appear to be corrupt, I changed the picture files, and saved them back to the original folder, now all is good.

    Thanks,
    Darryl.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Image Control automation error (Excel 2003)

    You can streamline the code a bit to avoid all those repetitions of similar lines:

    Private Sub TXTmass_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Dim strFile As String

    Select Case UCase(TXTmass.Value)
    Case "HENRY'S", "HENRYS"
    strFile = "HENRYS"
    Case "TIGER DIRECT"
    strFile = "TIGER_DIRECT"
    Case "MDG"
    strFile = "MDG"
    Case "TORONTO STAR MASS IMPACT"
    strFile = "TORONTOSTARBANNER"
    End Select

    strFile = "P:PlatemakingMiscINVENTORY_GRAPHICSMASS_IMPACT_GR APHICS" & strFile & ".jpg"
    Me.Image1.Picture = LoadPicture(strFile)
    Sheet6.worksheetImage1.Picture = LoadPicture(strFile)
    End Sub

  7. #7
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Image Control automation error (Excel 2003)

    Thanks Hans...works great!

Posting Permissions

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