Hi
I need your help guy.
Because the problem is some reference is no picture. but the result appear screen is "DEVICE UNAVAILABLE" supposed to display "NO PICTURE AVAILABLE" but no display the message and also not continue to find the other reference number after show the
"DEVICE UNAVAILABLE,
Example:
Picture Reference
batman.jpg btmn
CAT.jpg CT
--------------- Sprman (This area showing the "DEVICE UNAVAILABLE" after not found the picture and that no continue and stop to search the other reference.
Please advice..
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 = "julius:Users:apple:Desktop:royal_plaza_wincash:"
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.Left = .Left
S.Width = .Width
'S.LockAspectRatio = msoFalse
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 PICTURE 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 Shape
On Error Resume Next
Set P = ActiveSheet.Shapes.AddPicture(FName, False, True, 1, 1, -1, -1)
If Not P Is Nothing Then
Set InsertPicturePrim = P
P.Name = SName
End If
End Function
In window this code is working and also the message "NO PICTURE AVAILaBLE" is display and continue to find other reference.