0
Good afternoon!
I am using the code below to load images in excel of certain directory plus my formula is showing error.
Follows the code:
Public Function getImage(ByVal sCode As String) As String
Dim sFile As String
Dim oSheet As Worksheet
Dim oSell As Range
Dim oImage As Shape
Set oCell = Application.Caller
Set oSheet = oCell.Parent
Set oImage = Nothing
For i = 1 To oSheet.Shapes.Count
If oSheet.Shapes(i).Name = sCode Then
Set oImage = oSheet.Shapes(i)
Exit For
End If
Next i
If oImage Is Nothing Then
sFile = "C:\Temp\Nova pasta" & sCode & ".jpg"
Set oImage = oSheet.Shapes.AddPictute(sFille, msoCTrue, oCell.Left, oCell.Top, oCell.Width, oCell.Height)
oImage.Name = sCode
Else
With oImage
.Left = oCell.Left
.Top = oCell.Top
.Width = oCell.Width
.Height = oCell.Height
End With
End If
getImage = ""
End Function
Could someone help me identify the error of this formula?