import both images and the PDF document

KlausW

Active Member
Joined
Sep 9, 2020
Messages
453
Office Version
  1. 2016
Platform
  1. Windows
Hi Excel helpers.
Are there any that can help modify this VBA code that I use to import images with.
I would like to make it so that when I run the vba code it must be able to import both images and the PDF document I intend to use the FileLocation command.
And that Excel downloads all the files that are either images or PDF documents, at that location.
Furthermore, all the images / PDF documents must be the same size and placed in the center of the cells.
The names of the images / PDF documents are in cell B2 and down.
I use this VBA code to import pictures.
All help will be appreciated.
Klaus W
VBA Code:
Sub Rektangelafrundedehjørner3_Klik()

Dim pictname As String

Dim pastehere As Range

Dim pasterow As Long

Dim x As Long

Dim lastrow As Long

lastrow = Worksheets("Billeter").Range("B1").CurrentRegion.Rows.Count

x = 2

For x = 2 To lastrow

Set pastehere = Cells(x, 1)

pasterow = pastehere.Row

Cells(pasterow, 1).Select 'This is where picture will be inserted

pictname = Cells(x, 2) 'This is the picture name

If Len(Trim(pictname)) > 0 Then

ActiveSheet.Pictures.Insert("D:\F-div\Rejseafregning\" & pictname & ".jpg").Select 'Path to where pictures are stored

End If

With Selection

.Left = Cells(pasterow, 2).Left + (Cells(pasterow, 3).Width - .Width / 0.85)

.Top = Cells(pasterow, 2).Top + (Cells(pasterow, 1).Height - .Height / 0.9)

.ShapeRange.LockAspectRatio = msoFalse

.ShapeRange.Height = 400#

.ShapeRange.Width = 500#

.ShapeRange.Rotation = 0#

End With

Next

End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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