KlausW
Active Member
- Joined
- Sep 9, 2020
- Messages
- 453
- Office Version
- 2016
- Platform
- 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
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