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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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,215,430
Messages
6,124,850
Members
449,194
Latest member
HellScout

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