+ Reply to Thread
Results 1 to 2 of 2

Image display on cell based on number value (MAC)

  1. #1
    Forum Contributor
    Join Date
    10-02-2014
    Location
    Philippines
    MS-Off Ver
    MAC MS office 2019
    Posts
    121

    Image display on cell based on number value (MAC)

    Hi,

    I need your help guys to solve this my problem.

    I have a code for display the picture in excel.

    I try this in window pc but is already run and fine.

    But in the mac, I try this is run is fine but some number not found the picture then coming error "device unavailable" supposed to be display only "no pictures available" in column but not appear and stop.

    Now my question is how to solve this error in mac excel.

    here the code.



    Option Explicit

    Sub DeleteAllPictures()
    Dim S As Shape
    For Each S In ActiveSheet.Shapes
    Select Case S.Type
    Case msoLinkedPicture, msoPicture
    S.Delete
    End Select
    Next
    End Sub

    Sub UpdatePictures()
    Dim R As Range
    Dim S As Shape
    Dim Path As String, FName As String

    Path = "Transcend:royal_plaza_wincash:ALL:"


    If Right(Path, 1) <> ":" Then Path = Path & ":"

    For Each R In Range("B1", Range("B" & Rows.Count).End(xlUp))
    Set S = GetShapeByName(R)

    If S Is Nothing Then

    FName = Dir(Path & R & ".jpg")
    If FName <> "" Then
    Set S = InsertPicturePrim(Path & FName, R)
    End If
    End If
    If Not S Is Nothing Then
    If S.Name <> R Then R.Interior.Color = vbRed
    With R.Offset(0, -1)

    S.Top = .Top
    S.Width = .Width


    If S.LockAspectRatio Then
    If S.Height > .Height Then S.Height = .Height
    Else
    S.Height = .Height
    End If
    End With
    S.ZOrder msoSendToBack
    Else
    R.Offset(0, -1) = "No Pictures Available"
    End If
    Next
    End Sub
    Private Function GetShapeByName(ByVal SName As String) As Shape
    On Error Resume Next
    Set GetShapeByName = ActiveSheet.Shapes(SName)
    End Function

    Private Function InsertPicturePrim(ByVal FName As String, ByVal SName As String) As Shape
    Dim P As Picture
    On Error Resume Next
    Set P = ActiveSheet.Pictures.Insert(FName)
    If Not P Is Nothing Then
    Set InsertPicturePrim = P.ShapeRange(1)
    P.Name = SName
    End If
    End Function

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166
    Hello jc83ph,

    Welcome to Excelforum. Be a part of large Excel community. Enjoy Learning.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Display an image based on a cell's value?
    By proepert in forum Excel General
    Replies: 8
    Last Post: 11-06-2014, 03:39 PM
  2. Display an image based on a cell's value in 2007
    By Ashurk77 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-06-2013, 10:48 AM
  3. Display image, from file, based on a cell value
    By Static Cat in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-13-2013, 06:45 AM
  4. Display Image Based On Image Name In Cell
    By processchip in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2011, 10:11 AM
  5. Display Image Based on Cell Content
    By Mark Talbot in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-20-2007, 08:29 AM

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