K
K
Kryptonit2022-04-19 11:36:59
Visual Basic
Kryptonit, 2022-04-19 11:36:59

How to fix Vba error 1004?

Good afternoon, I want to insert a picture into a sheet in a book, I found this code

With Worksheets(lstname).Pictures.Insert(PicPath)
    With .ShapeRange
        .LockAspectRatio = msoTrue
        .Width = 75
        .Height = 100
    End With
    .Left = Worksheets(lstname).Cells(5, 5).Left
    .Top = Worksheets(lstname).Cells(5, 5).Top
    .Placement = 1
    .PrintObject = True
End With


However, the error "Run-time Error 1004: Unable to get the Insert property of the pictures class" occurs.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nektopme, 2022-04-21
@nektopme

Good afternoon!
Look at the value of the PicPath variable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question