KlausW
Active Member
- Joined
- Sep 9, 2020
- Messages
- 458
- Office Version
- 2016
- Platform
- Windows
Hi all, I get this error message when I run the VBA code, “Unable to get the Insert property of the Picture Class”. The VBA code, Showing images from a folder in a column in a sheet.
Some who can help. I have looked at this question here in the Forum
but cannot figure out how to merge the solution into my VBA code.
Some who can help. Any help will be appreciated.
Best regards Klaus W
Help from this Forum
Some who can help. I have looked at this question here in the Forum
but cannot figure out how to merge the solution into my VBA code.
Some who can help. Any help will be appreciated.
Best regards Klaus W
Help from this Forum
VBA Code:
Sub Sheet1_Rektangelafrundedehjørner1_Klik()
Dim pictname As String
Dim pastehere As Range
Dim pasterow As Long
Dim x As Long
Dim lastrow As Long
lastrow = Worksheets("Sheet1").Range("a1").CurrentRegion.Rows.Count
x = 2
For x = 2 To lastrow
Set pastehere = Cells(x, 1)
pasterow = pastehere.Row
Cells(pasterow, 2).Select 'This is where picture will be inserted
pictname = Cells(x, 1) 'This is the picture name
ActiveSheet.Pictures.Insert("D:\Billeder af VPL - Kopi\" & pictname & ".jpg").Select 'Path to where pictures are stored
With Selection
.Left = Cells(pasterow, 2).Left + (Cells(pasterow, 2).Width - .Width / 1)
.Top = Cells(pasterow, 2).Top + (Cells(pasterow, 2).Height - .Height / 1)
'.Left = Cells(pasterow, 1).Left
'.Top = Cells(pasterow, 0.5).Top
.ShapeRange.LockAspectRatio = msoFalse
.ShapeRange.Height = 120#
.ShapeRange.Width = 75#
.ShapeRange.Rotation = 0#
End With
Next
Range("a1").Select
End Sub