gatobarbieri
New Member
- Joined
- Jun 27, 2022
- Messages
- 5
- Office Version
- 2021
- Platform
- Windows
Hi I found this macro to insert several pictures but the problem is resize them and I need to keep the original size of pictures. Is there any instruction to make it. This is the macro that I used. Thanks
Sub INSERTPHOTOS()
Dim PosX, PosY, X, J As Integer
Dim QuanPic As Integer
Dim Route As String
Route = "C:\MYPICTURES\"
Quantity of pictures to load
QuanPic = 200
Left margin and upper margin to separate each picture
PosX = 30
PosY = 30
J = 1
If there is any shape it will be eliminating.
If ActiveSheet.DrawingObjects.Count > 0 Then
ActiveSheet.DrawingObjects.Select
Selection.Delete
End If
and I load the 200 pics from the directory.
For X = 1 To QuanPic
This If is to put new values and make 2 pictures per row
'este If es para asignar nuevos valores a las
If J = 3 Then
PosX = 30
PosY = PosY + 330
J = 1
End If
I insert the shape and left margin and upper margin I put the variables, and I fix the width and heigh in 200 units (this mesuarment I need to take from original size of pic)
'inserto una autoforma y como margen izq. y superior le paso las
ActiveSheet.Shapes.AddShape(msoShapeRectangle, PosX, PosY, 240, 240).Select
I indicate load the pictures used the variable Route and conecting number of picture with extension jpg
On Error Resume Next
Selection.ShapeRange.Fill.UserPicture _
Route & "Image" & X & ".jpg"
If Err.Number <> 0 Then
MsgBox "No find one of the pictures " _
& " check the directory ", vbCritical, "Error"
Err.Clear
Exit Sub
End If
Increase the left margin and to J
PosX = PosX + 330
J = J + 1
Next X
Range("a1").Select
End Sub '
Sub INSERTPHOTOS()
Dim PosX, PosY, X, J As Integer
Dim QuanPic As Integer
Dim Route As String
Route = "C:\MYPICTURES\"
Quantity of pictures to load
QuanPic = 200
Left margin and upper margin to separate each picture
PosX = 30
PosY = 30
J = 1
If there is any shape it will be eliminating.
If ActiveSheet.DrawingObjects.Count > 0 Then
ActiveSheet.DrawingObjects.Select
Selection.Delete
End If
and I load the 200 pics from the directory.
For X = 1 To QuanPic
This If is to put new values and make 2 pictures per row
'este If es para asignar nuevos valores a las
If J = 3 Then
PosX = 30
PosY = PosY + 330
J = 1
End If
I insert the shape and left margin and upper margin I put the variables, and I fix the width and heigh in 200 units (this mesuarment I need to take from original size of pic)
'inserto una autoforma y como margen izq. y superior le paso las
ActiveSheet.Shapes.AddShape(msoShapeRectangle, PosX, PosY, 240, 240).Select
I indicate load the pictures used the variable Route and conecting number of picture with extension jpg
On Error Resume Next
Selection.ShapeRange.Fill.UserPicture _
Route & "Image" & X & ".jpg"
If Err.Number <> 0 Then
MsgBox "No find one of the pictures " _
& " check the directory ", vbCritical, "Error"
Err.Clear
Exit Sub
End If
Increase the left margin and to J
PosX = PosX + 330
J = J + 1
Next X
Range("a1").Select
End Sub '