ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Insert Picture (https://www.excelbanter.com/excel-discussion-misc-queries/77560-insert-picture.html)

maximus73

Insert Picture
 

when I use, ActiveSheet.Pictures.Insert(stringVariable).Select , I
receive the following error.

Runtime error '1004':

Unable to get the Insert property of the Pictures class

If I use, ActiveSheet.Pictures.Insert("c:\mypicture.jpg").se lect, it
works fine.

??????


--
maximus73
------------------------------------------------------------------------
maximus73's Profile: http://www.excelforum.com/member.php...o&userid=25877
View this thread: http://www.excelforum.com/showthread...hreadid=522865


Dave Peterson

Insert Picture
 
I'd guess that your stringVariable doesn't contain a real filename--just a
typo???

I'd check first:

Dim StringVariable As String
Dim testStr As String
Dim myPict As Picture

StringVariable = "C:\asdf.jpg"

testStr = ""
On Error Resume Next
testStr = Dir(StringVariable)
On Error GoTo 0

If testStr = "" Then
MsgBox StringVariable & " doesn't exist"
Else
Set myPict = ActiveSheet.Pictures.Insert(StringVariable)
End If




maximus73 wrote:

when I use, ActiveSheet.Pictures.Insert(stringVariable).Select , I
receive the following error.

Runtime error '1004':

Unable to get the Insert property of the Pictures class

If I use, ActiveSheet.Pictures.Insert("c:\mypicture.jpg").se lect, it
works fine.

??????

--
maximus73
------------------------------------------------------------------------
maximus73's Profile: http://www.excelforum.com/member.php...o&userid=25877
View this thread: http://www.excelforum.com/showthread...hreadid=522865


--

Dave Peterson


All times are GMT +1. The time now is 02:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com