Insert multiple pictures and arrange them with numbers

johanlof

New Member
Joined
Jan 18, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi,

I've been trying to create a macro for entering mulitple pictures to an invoice and number them so I can refer to them in the descriptive text in the invoice.

So far i've tried many different macros but the only one that organizes the picture in the way I want is this code which I found on this forum.

HOWEVER,
On top of this macro I want to open the file explorer, select the pictures I want and organize them in the same way as the macro below.
And if it's possible to number them at the same time.

VBA Code:
Sub organizeImages()

     lastTop = 765
     staticHeight = 350

     For Each pic In Worksheets("Fakturaunderlag").Pictures
          pic.Top = lastTop
          pic.Height = staticHeight
          lastTop = lastTop + pic.Height + 25
          pic.Left = 25
     Next pic
End Sub

Thanks in advance!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
This one works but not with MultiSelect set to True.
Is there something i'm missing?
VBA Code:
Sub organizeImages()

Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported", MultiSelect:=True)
If fNameAndPath = False Then Exit Sub
    Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
    With img
     lastTop = 765
     staticHeight = 350

     For Each pic In Worksheets("Fakturaunderlag").Pictures
          pic.Top = lastTop
          pic.Height = staticHeight
          lastTop = lastTop + pic.Height + 25
          pic.Left = 25
     Next pic
    End With
    

End Sub
 
Upvote 0

Forum statistics

Threads
1,216,077
Messages
6,128,684
Members
449,463
Latest member
Jojomen56

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