View Full Version : Run-time error '1004' Unable to get the Insert property of Pictures class
mancubus
02-21-2011, 05:46 AM
hi all.
below code works fine at home but gives RTE 1004 when used in the office.
when i copy the image link in the browser's address bar, the image is displayed. and also there is no problem copying the image to a folder via some other code.
is it stg related with internet policy or do i have to reference to a library/application from tools in VBE. or stg else?
Sub pixadd()
Dim cll As Range
Dim pth As String
Dim pix As Object
For Each cll In Worksheets("Sheet1").Range("A2:A10")
pth = "http://xxx.com/images/" & cll.Value & ".jpg"
Set pix = Worksheets("Sheet2").Pictures.Insert(pth)
Next
End Sub
IBihy
02-21-2011, 09:50 AM
Hello,
First of all, I'm using Excel2003, and I have not found a Pictures property, neither within the worksheet object, nor a range object.
mancubus
02-21-2011, 10:32 AM
thanks for the reply ibihy.
property is "Insert", and class is "Picture".
ps:
- code works in xl2003.
- but not in xl2007 (when i try with office pc. again no problem with my own pc at home.).
shrivallabha
02-21-2011, 11:18 PM
Maybe even this went out of the "window" like application.filesearch. Try it with macro recorder in xl2007, see where it does it go?
mancubus
02-21-2011, 11:49 PM
thanks shrivallabha.
recorder produces nothing.
Sub Macro1()
'
' Macro1 Macro
'
'
End Sub
shrivallabha
02-22-2011, 12:18 AM
Not a good sign. Same here. I tried with XL2003 and it does show the code above so probably, this class and method are not available anymore.
Maybe we should wait for expert comment here and it will be better to post on MSDN's social forum to see if there's any workaround for this.
And I hope, you are not serious @ URL above :devil2: !
mancubus
02-22-2011, 12:47 AM
thanks.
but interesting point is, it works in 2007 with home pc. :dunno
mancubus
02-22-2011, 12:50 AM
and when i copy the url to (insert/picture) "file name:" the image is inserted.
and yes.
not serious about xxx.com. even did not check if it is a valid url. :rofl:
mancubus
02-22-2011, 12:56 AM
one more.
if the path to image is a hdd/server folder, there is no problem with insert property.
this works fine:
Sub pixadd()
Dim pth As String
Dim pix As Object
pth = "H:\images\image1.jpg"
Set pix = Worksheets("Sheet2").Pictures.Insert(pth)
End Sub
shrivallabha
08-29-2011, 07:02 AM
It stayed at the back of my mind. See here:
http://social.msdn.microsoft.com/Forums/en-US/exceldev/thread/b716f956-0cd4-4756-bd4a-281611e56552
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.