CutterJaxx
Technical User
Hi all,
Running Windows XP, Excel 2003
I have a macro which allows me to insert pictures every nth cell with a predefined starting cell. As more pictures need to be added at a later date I need to facilitate the insertion of pictures after the last picture inserted and at the same intervals.
Can I either a
rompt the user for the new starting cell
or b: find the last inserted picture automatically and set the new starting cell based on its location.
Below is the existing code.
As always,
Any and all assistance greatly appreciated.
Cutter
Running Windows XP, Excel 2003
I have a macro which allows me to insert pictures every nth cell with a predefined starting cell. As more pictures need to be added at a later date I need to facilitate the insertion of pictures after the last picture inserted and at the same intervals.
Can I either a
or b: find the last inserted picture automatically and set the new starting cell based on its location.
Below is the existing code.
Code:
Sub Insert_Pict()
Dim Pict() As Variant
Dim ImgFileFormat As String
Dim PictCell As Range
Dim Ans As Integer
Dim newPicture As Shape
Dim lrow As Long, lLoop As Long
Dim lTop As Long
Dim sShape As Shape
ImgFileFormat = "Image Files jpg (*.jpg),*.jpg,(*.bmp),others, tif (*.tif),*.tif"
GetPict:
Pict = Application.GetOpenFilename(ImgFileFormat, MultiSelect:=True)
'Note you can load in any nearly file format
If Not IsArray(Pict) Then
Debug.Print "No files selected."
Exit Sub
End If
lrow = 3
For lLoop = LBound(Pict) To UBound(Pict)
lTop = Cells(lrow, "A").Top
Set sShape = ActiveSheet.Shapes.AddPicture(Pict(lLoop), msoFalse, msoCTrue, Cells(1, 3).Left, lTop, 622, 467)
'expression.AddPicture(Filename, LinkToFile, SaveWithDocument, Left, Top, Width, Height)
With sShape
.LockAspectRatio = msoTrue
End With
lrow = lrow + 45
Next lLoop
End Sub
As always,
Any and all assistance greatly appreciated.
Cutter