![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 1
|
I insert a picture in my excel file with vb :
ActiveSheet.Pictures.Insert(sServerPath + SignatureFile) Next, I would like to delete it in order to replace it. I do : ActiveSheet.pictures(0).delete() but it doesn't work. Why? How can I do? |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: Georgia USA
Posts: 544
|
Try this
For Each Shape In ActiveSheet.Shapes If Shape.Type = msoPicture Then Shape.Delete End If Next Shape |
|
|
|
|
|
#3 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
To delete it then you must explicitly name the Picture eg. ' ' Sub Tester1() ActiveSheet.Shapes("Picture 1").Delete End Sub ' ' Note: That when creating pictures via inserting the Picture name (That you see to the right of the Formula bar = Name Box) will always increment the name of the Picture eg Picture 1, Picture 2 etc. so inserting and then deleting them will always change the name. To get around this you can do one of two things. 1) Name your pictures when you insert it 2) Delete ALL pictures..this may not suit but you can always be selective in your coding; eg. ' ' Sub Tester2() Dim Pict As Object For Each Pict In ActiveSheet.Shapes If Pict.Type = 13 Then Pict.Delete End If Next End Sub Sub Tester3() '// Name your Picture when inserting ActiveSheet.Pictures.Insert(sServerPath + SignatureFile).Name = "Test" End Sub |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|