Hello!
i am using this code to import pictures into my worksheet. After they are imported, the pictures are cropped and then placed in cell B3 and downward (B3, B4, B5, etc.)
Sub InsertAllPictures()
Dim strPath As String
Dim strFileName As String
Dim shpTemp As Shape
Dim rngOutput As Range
Dim Alert As String
Rows("3:50").Select
Selection.RowHeight = 140 ' Set row height to 150px
Columns("B:B").Select
Selection.ColumnWidth = 20 ' Set column width to 20px
Range("B3").Select
strPath = GetFolderName("Select a folder")
strFileName = Dir(strPath & "\" & "*.bmp")
Alert = MsgBox("You selected this folder:" & strPath & "\" & strFileName, 0, "Your Selection")
Set rngOutput = ActiveSheet.Range("B3")
Do While Len(strFileName) > 0
ActiveSheet.Pictures.Insert strPath + "\" + strFileName
Set shpTemp = ActiveSheet.Shapes(ActiveSheet.Shapes.Count)
With shpTemp
With .PictureFormat
.CropLeft = 269
.CropTop = 142
.CropBottom = 309
.CropRight = 402
End With
.Left = rngOutput.Left
.Top = rngOutput.Top
End With
Set rngOutput = rngOutput.Offset(1, 0)
strFileName = Dir
Loop
End Sub
However, the code is running perfectly fine, but the whole process which this macro is implemented is too complicated. Now, I would like to know if someone could help me please to arrange that the macro to do the following:
1. impot the pictures (already done by macro)
2. crop the pictures (already done by macro)
3. I have a key number starting from A3 downwards (1, 2, 3, etc) and if the FILENAME of the picture (1.bmp, 2.bmp, 3.bmp) is the same as this key number, insert the picture in column B of that row.
Hope someone understands what I mean!
Thanks a lot!!!!!
A2k
Bookmarks