Hey guys
Can someone please help me fix up my VBA code ? :'(
Here is my current code:
Basically I would like to insert jpg images into coln B from a folder. The names of the pictures are based in the text values in coln A.
That is currently working however I would like to make 2 improvements.
Improvement 1 is if the image doesn't exist skip it. (At the moment I have the resume next but I hear this isn't good coding)
Improvement 2 which is the main issue:
The images are different sizes some are way too big. I would like to insert it into the cell and make the height of the cell be the limiting factor and scale it to scale (aspect ratio)?
Can someone please help?
Can someone please help me fix up my VBA code ? :'(
Here is my current code:
Code:
Sub PlacePics() Dim Path As String, Pics As Range, Pic As Range, Pix As Picture
On Error Resume Next
Path = "C:\Users\Panda\Pictures\"
Set Pics = ActiveSheet.Range("A9:A504")
For Each Pic In Pics
Pic.Offset(0, 1).Select
Set Pix = ActiveSheet.Pictures.Insert(Path & Pic.Value & ".jpg").Select
With Pic
.ShapeRange.LockAspectRatio = msoFalse
.Left = ImageCell.Left
.Top = ImageCell.Top
.Width = ImageCell.Width
.Height = ImageCell.Height
End With
Next Pic
End Sub
Basically I would like to insert jpg images into coln B from a folder. The names of the pictures are based in the text values in coln A.
That is currently working however I would like to make 2 improvements.
Improvement 1 is if the image doesn't exist skip it. (At the moment I have the resume next but I hear this isn't good coding)
Improvement 2 which is the main issue:
The images are different sizes some are way too big. I would like to insert it into the cell and make the height of the cell be the limiting factor and scale it to scale (aspect ratio)?
Can someone please help?