Question about Pictures in Excel

T

TyeJae

Maybe I should explain more in detail...here is what I have...

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cance
As Boolean)

Dim testStr As String
Dim myFileName As String
Dim myPict As Picture

Set Target = Target(1)

myFileName = "C:\Documents and Settings\ahoekst\My Documents\DirectX
_
& "\My Pictures\" _
& Me.Cells(Target.Row, "D").Value _
& ".jpg"

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

If testStr = "" Then
MsgBox "file not found"
Exit Sub
End If

Cancel = True
With Me.Cells("3", "b")
Set myPict = .Parent.Pictures.Insert(myFileName)
myPict.Top = .Top
myPict.Left = .Left
' myPict.Width = .Width
' myPict.Height = .Height
myPict.Placement = xlMoveAndSize
myPict.Name = "Card"
End With

End Sub

Basically what I want it to do is whenever I double click a new cell
delete any pictures/shapes that were previously inserted, whether ther
is a picture in the sheet or not. I tried adding the statement below
but when there is not a picture in the sheet in errors.

ActiveSheet.Shapes("Card").Select
Selection.Delet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top