Inserting a picture with Path name in a Variable [Closed]

Report
Posts
6
Registration date
Monday October 24, 2016
Status
Member
Last seen
November 24, 2016
-
 Blocked Profile -
Hello Guys,

I am getting an "Error 1004: unable to get insert property of Picture class" with the following code. Looking forward for your guidance. Thanks in Advance :)

Sub newfile()

Dim x As String

x = Application.GetOpenFilename()

ActiveSheet.Pictures.Insert("x").Select


End Sub

1 reply


You are trying to insert your VBA project name with that method! The application, is the one running, which would be Excel. Then the method on the application would be your excel sheet file name.

Try this:
Dim x

X = "C:\mydocuments\thepicturename.png"

ActiveSheet.Pictures.Insert(X)


Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!