Landshark24
New Member
- Joined
- Oct 27, 2019
- Messages
- 6
Hi there,
I have VBA to insert images from a filepath which is derived from a formula. The images insert just fine and are visible for me but if someone else opens the documents they cannot be seen (all settings are correct). I'm assuming I need to embed the images but cannot quite get the code correct. Here is the original code:
Any suggestions much appreicated
NOTE: Have tried simply copying and pasting the images after the VBA is run, but it seems to only work sometimes. Other times the image are still unavailable
I have VBA to insert images from a filepath which is derived from a formula. The images insert just fine and are visible for me but if someone else opens the documents they cannot be seen (all settings are correct). I'm assuming I need to embed the images but cannot quite get the code correct. Here is the original code:
Code:
Sub URLPictureInsert()
Dim Pshp As Shape
Dim xRg As Range
Dim xCol As Long
On Error Resume Next
Application.ScreenUpdating = False
Set Rng = ActiveSheet.Range("B52")
For Each cell In Rng
filenam = cell
ActiveSheet.Pictures.Insert(filenam).Select
Set Pshp = Selection.ShapeRange.Item(1)
If Pshp Is Nothing Then GoTo lab
xCol = cell.Column
Set xRg = Cells(cell.Row, xCol)
With Selection
.ShapeRange.LockAspectRatio = msoTrue
If (.Height \ .Width) <= (Rng.Height \ Rng.Width) Then
.Width = Rng.Width - 1
.Left = Rng.Left + 1
.Top = Rng.Top + ((Rng.Height - Selection.Height) / 2)
Else
.Top = Rng.Top + 1
.Height = Rng.Height - 1
.Left = Rng.Left + ((Rng.Width - Selection.Width) / 2)
End If
.Placement = xlMoveAndSize
.PrintObject = True
End With
lab:
Set Pshp = Nothing
Range("B52").Select
Next
Application.ScreenUpdating = True
End Sub
NOTE: Have tried simply copying and pasting the images after the VBA is run, but it seems to only work sometimes. Other times the image are still unavailable
Last edited by a moderator: