Hi all, I created a macro to insert pictures to Excel from files based on item numbers. Everything works great except every time you open the file, it needs to pull the images from the files. The location is a network drive, so if somebody wants to open the sheet from a location not connected to our network, the images don't display. Is there a way to save the images in the file for good? Ill post my code below.
THANKS!!!
Sub getImages()
'
' getImages Macro
' gets images
'
' Keyboard Shortcut: Ctrl+i
Dim sFileName As String
Dim bContinue As Boolean
Dim beenHereBefore As Boolean
Dim i As Integer
Dim h As Integer
Dim w As Integer
Dim t As Integer
Dim l As Integer
i = 2
bContinue = True
sFileName = Sheet1.Cells(i, "b")
While bContinue
Sheet1.Cells(i, "a").Select
Selection.RowHeight = 60
Selection.ColumnWidth = 17
h = Selection.Height
w = Selection.Width
t = Selection.Top
l = Selection.Left
'select the cell where it should be inserted
sPath = "\\Pbk3\CounterPointSQL\PrimitivesSQL\ItemImages\" & sFileName & ".jpg"
ActiveSheet.Pictures.Insert(sPath).Select
'inserts picture and select it
Selection.ShapeRange.Width = 40
Selection.ShapeRange.Height = 40
Selection.ShapeRange.Left = (l + w / 2) - (Selection.ShapeRange.Width / 2)
Selection.ShapeRange.Top = (t + h / 2) - (Selection.ShapeRange.Height / 2)
i = i + 1
sFileName = Sheet1.Cells(i, "b")
If sFileName = "" Then
bContinue = False
End If
Wend
End Sub
Bookmarks