excelbeginner1
New Member
- Joined
- Dec 13, 2014
- Messages
- 20
Good day
Please could you assist I need to align my imported images
this is the vba code I am currently using to import.
Sub PictureKiller()
Dim s As Shape, rng As Range
Set rng = Range("c6:c99999")
For Each s In ActiveSheet.Shapes
If Intersect(rng, s.TopLeftCell) Is Nothing Then
Else
s.Delete
End If
Next s
Const fPath = "H:\FURNITURE PICS\ALL PICS"
Dim cel As Range, picPath As String
For Each cel In Range("a6", Range("a" & Rows.Count).End(xlUp))
On Error Resume Next
picPath = fPath & "\" & cel.Value & ".jpg"
If Not Dir(picPath, vbDirectory) = vbNullString Then
With cel.Parent.Pictures.Insert(picPath)
With .ShapeRange
.LockAspectRatio = msoFalse
.Width = 310
.Height = 310
End With
.Left = cel.Offset(, 2).Left
.Top = cel.Offset(, 2).Top
End With
End If
Next cel
End Sub
currently the images are are the left of the cell.
I want to center the images in there respective cells,.
Please could you assist I need to align my imported images
this is the vba code I am currently using to import.
Sub PictureKiller()
Dim s As Shape, rng As Range
Set rng = Range("c6:c99999")
For Each s In ActiveSheet.Shapes
If Intersect(rng, s.TopLeftCell) Is Nothing Then
Else
s.Delete
End If
Next s
Const fPath = "H:\FURNITURE PICS\ALL PICS"
Dim cel As Range, picPath As String
For Each cel In Range("a6", Range("a" & Rows.Count).End(xlUp))
On Error Resume Next
picPath = fPath & "\" & cel.Value & ".jpg"
If Not Dir(picPath, vbDirectory) = vbNullString Then
With cel.Parent.Pictures.Insert(picPath)
With .ShapeRange
.LockAspectRatio = msoFalse
.Width = 310
.Height = 310
End With
.Left = cel.Offset(, 2).Left
.Top = cel.Offset(, 2).Top
End With
End If
Next cel
End Sub
currently the images are are the left of the cell.
I want to center the images in there respective cells,.