Hi again gang,
Below is a piece of code that I wrangled together for the specific purpose of inserting product images into any spreadsheet where
Dim MyPictureFile As String
Dim MyCell As Range
Dim counter As Integer
counter = 15
Do While ActiveSheet.Range("e" & counter) <> 0
If ActiveSheet.Range("c" & counter) <> 0 Then
namedcell = ActiveSheet.Range("C" & counter).Value
If FileFolderExists("\\Myservername\Accounting\Kurt\John\Projects\Thumbnail image excel mouseover\S09publisherjpgs\" & namedcell & ".jpg") Then
MyPictureFile = "\\Myservername\Accounting\Kurt\John\Projects\Thumbnail image excel mouseover\S09publisherjpgs\" & namedcell & ".jpg"
With ActiveSheet
Set MyCell = .Range("A" & counter)
.Pictures.Insert(MyPictureFile).Select
'---------------------------------------------------------------------
With MyCell
Selection.Top = .Top
Selection.Left = .Left
Selection.Width = .Width
Selection.Height = .Height
Selection.Placement = xlMoveAndSize ' move and size with cells
Selection.PrintObject = True
'-------------------------------------------------------------
'Selection.ShapeRange.PictureFormat.Brightness = 0.5 ' various formats available
'-------------------------------------------------------------
'-
.Select ' change focus (selection) from picture to cell
End With
'---------------------------------------------------------------------
End With
Else
With ActiveSheet
.Range("a" & counter) = "Picture N/A"
End With
End If
End If
counter = counter + 1
Loop
End Sub
Public Function FileFolderExists(strFullPath As String) As Boolean
'Macro Purpose: Check if a file or folder exists
On Error GoTo EarlyExit
If Not Dir(strFullPath, vbDirectory) = vbNullString Then FileFolderExists = True
EarlyExit:
On Error GoTo 0
End Function
It works, but the images are linked to the network path. This is a problem because I want to be able to send the files (with images) to customers outside my network.
How can I embed the images in the sheet so that it can be shared?
John
Below is a piece of code that I wrangled together for the specific purpose of inserting product images into any spreadsheet where
- the product number is in column "c"
- Product image library contains thumbnail images with a file name equal to the product number (saved in \\Myservername\Accounting\Kurt\John\Projects\Thumbnail)
Dim MyPictureFile As String
Dim MyCell As Range
Dim counter As Integer
counter = 15
Do While ActiveSheet.Range("e" & counter) <> 0
If ActiveSheet.Range("c" & counter) <> 0 Then
namedcell = ActiveSheet.Range("C" & counter).Value
If FileFolderExists("\\Myservername\Accounting\Kurt\John\Projects\Thumbnail image excel mouseover\S09publisherjpgs\" & namedcell & ".jpg") Then
MyPictureFile = "\\Myservername\Accounting\Kurt\John\Projects\Thumbnail image excel mouseover\S09publisherjpgs\" & namedcell & ".jpg"
With ActiveSheet
Set MyCell = .Range("A" & counter)
.Pictures.Insert(MyPictureFile).Select
'---------------------------------------------------------------------
With MyCell
Selection.Top = .Top
Selection.Left = .Left
Selection.Width = .Width
Selection.Height = .Height
Selection.Placement = xlMoveAndSize ' move and size with cells
Selection.PrintObject = True
'-------------------------------------------------------------
'Selection.ShapeRange.PictureFormat.Brightness = 0.5 ' various formats available
'-------------------------------------------------------------
'-
.Select ' change focus (selection) from picture to cell
End With
'---------------------------------------------------------------------
End With
Else
With ActiveSheet
.Range("a" & counter) = "Picture N/A"
End With
End If
End If
counter = counter + 1
Loop
End Sub
Public Function FileFolderExists(strFullPath As String) As Boolean
'Macro Purpose: Check if a file or folder exists
On Error GoTo EarlyExit
If Not Dir(strFullPath, vbDirectory) = vbNullString Then FileFolderExists = True
EarlyExit:
On Error GoTo 0
End Function
It works, but the images are linked to the network path. This is a problem because I want to be able to send the files (with images) to customers outside my network.
How can I embed the images in the sheet so that it can be shared?
John