Inserting a picture with Path name in a Variable

Closed
adikademani Posts 5 Registration date Monday October 24, 2016 Status Member Last seen November 24, 2016 - Nov 9, 2016 at 02:39 PM
 Blocked Profile - Nov 9, 2016 at 04:59 PM
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 response

Blocked Profile
Nov 9, 2016 at 04:59 PM
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)


0