Deleting pictures using VBA??

R

Richard1284

Hi all,

Can anyone help me, I have inserted a picture
ie.
ActiveSheet.Pictures.Insert("F:\Dss\ass\Arran1.jpg").Select

Now all I want to do is delete it using VBA. Unfortunately I have n
idea. When I tried ActiveSheet.Pictures.Delete it deletes my cmdButton
too.

Any ideas??
 
B

Bob Phillips

Hi Richard,

When you open the picture, set a variable to that pic, like so

Dim myPic As Picture
Dim sPic As String

sPic = ("F:\Dss\ass\Arran1.jpg"
Set myPic = ActiveSheet.Pictures.Insert(sPic)

and then you can simply delete it via the variable

myPic.Delete


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
B

Bob Phillips

small typo, should be

Dim myPic As Picture
Dim sPic As String

sPic = "F:\Dss\ass\Arran1.jpg"
Set myPic = ActiveSheet.Pictures.Insert(sPic)


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Bob Phillips said:
Hi Richard,

When you open the picture, set a variable to that pic, like so

Dim myPic As Picture
Dim sPic As String

sPic = ("F:\Dss\ass\Arran1.jpg"
Set myPic = ActiveSheet.Pictures.Insert(sPic)

and then you can simply delete it via the variable

myPic.Delete


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
T

Tushar Mehta

For a continuation of this discussion, see the concurrent subject
'Sorry here it is again' in the same newsgroup.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
Top