How do I insert images in next row?

VBA_Noob_Help

New Member
Joined
May 22, 2023
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
As the title states, I have 0 knowledge about enabling a new image to be inserted into the next row. My code is as follows:
------------------------------------------------------------------------------------------------------------
MsgBox ("Ensure that e-Signature is in PNG/JPG format"), , ("IMPORTANT")

Dim fNameAndPath As Variant
Dim img As Shape

fNameAndPath = Application.GetOpenFilename(Title:="Attach e-Signature")
If fNameAndPath = False Then Exit Sub
Set img = ThisWorkbook.Sheets("Human Resource Store").Shapes.AddPicture(Filename:=fNameAndPath, _
LinkToFile:=False, SaveWithDocument:=True, _
Left:=1, Top:=1, Width:=-1, Height:=-1)
With img
'Resize Picture to fit in the range....
.Left = ThisWorkbook.Sheets("Human Resource Store").Range("G2").Left
.Top = ThisWorkbook.Sheets("Human Resource Store").Range("G2").Top
.Width = ThisWorkbook.Sheets("Human Resource Store").Range("G2").Width
.Height = ThisWorkbook.Sheets("Human Resource Store").Range("G2").Height
.Placement = 1
.DrawingObject.PrintObject = True
End With

ws_output = "Human Resource Store"

next_row = Sheets(ws_output).Range("B" & Rows.Count).End(xlUp).Offset(1).Row

Sheets(ws_output).Cells(next_row, 1).Value = Range("B5").Value
Sheets(ws_output).Cells(next_row, 2).Value = Range("B7").Value
Sheets(ws_output).Cells(next_row, 3).Value = Range("B9").Value
Sheets(ws_output).Cells(next_row, 4).Value = Range("B11").Value
Sheets(ws_output).Cells(next_row, 5).Value = Range("B13").Value
Sheets(ws_output).Cells(next_row, 6).Value = Range("B15").Value


MsgBox ("Successfully submitted. Please send the excel file back")
------------------------------------------------------------------------------------------------------------
I understand that I am setting it to G2 in another sheet, but I just have no clue on how to enable the image to go to row G3? Please help.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
And the question is?????
Of course, a concise explanation helps.

BTW, putting the code between code tags makes it so much easier to decipher.
 

Attachments

  • Use Code Tags MrExcel.JPG
    Use Code Tags MrExcel.JPG
    50.2 KB · Views: 19
Upvote 0
And the question is?????
Of course, a concise explanation helps.

BTW, putting the code between code tags makes it so much easier to decipher.
Sorry, this is my first time using this.

I'm trying to create a form where one can import their e-Signatures every time. However, these 'e-Signatures' are compiling at G2, I assume I need a loop to ensure new images go to G3, G4, and so on. However I have zero coding background and no idea how to do that. Thank you!
 
Upvote 0
You want to bring in pictures, doesn't matter if they are e-signatures, photos or whatever, and place them in a cell.
Picture should be sized to cell dimensions.
Next picture should be in the next cell down and so on. Or is it 2 rows down?
Are the names of these pictures in Column B?
What is in these cells? Picture name including extension?
By the looks of your code, you want to choose the folder where the pictures are. Is that right?
Have a quick peek at the post here and see if that is close to what you have in mind.

The whole thing seems pretty straight forward but like I asked, we need concise information.

Or do you want to import just one picture and later another one but make sure it will get placed below the last picture?
 
Upvote 0
Here are a couple examples to try. Results are in different columns but it is only for you to try so you can let us know what needs changing.
Maybe just make some test runs in an empty workbook.

Just a couple examples with a Folder Picker where the pictures are located.

Picture names, including the extension but not the path, are in Column B.
Pictures will be placed in Column A, starting at Row 1.
Code:
Sub Single_Picture()
Dim strPath As String
    With Application.FileDialog(msoFileDialogFolderPicker)
        .AllowMultiSelect = False
        .Title = "Choose a picture folder."
        If .Show = -1 Then
            strPath = .SelectedItems(1)
        Else
            MsgBox "No folder selected!", vbCritical + vbOKOnly
            Exit Sub
        End If
    End With
ActiveSheet.Shapes.AddPicture(strPath & "\" & Range("B1").Value, 0, -1, Cells(1, 1).Left, Cells(1, 1).Top, Cells(1, 1).Width, Cells(1, 1).Height).Name = "Picture 1"
End Sub
Code:
Sub All_Pics_In_Column_B()
Dim strPath As String, c As Range
    With Application.FileDialog(msoFileDialogFolderPicker)
        .AllowMultiSelect = False
        .Title = "Select Folder That Has The Pictures."
        If .Show = -1 Then
            strPath = .SelectedItems(1)
        Else
            MsgBox "No folder selected!", vbCritical + vbOKOnly
            Exit Sub
        End If
    End With
For Each c In Range("A1:A" & Cells(Rows.Count, 2).End(xlUp).Row)
    ActiveSheet.Shapes.AddPicture(strPath & "\" & c.Offset(, 1).Value, 0, -1, c.Left, c.Top, c.Width, c.Height).Name = Left(c.Offset(, 1).Value, InStr(c.Offset(, 1), ".") - 1)
Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top