Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to edit the code to insert more than 1 image?

Does anyone have any suggestions on how to edit the following code to insert
more than 1 image?
If A1 = 1, then display image from ("C:\TempPic.JPG"), else
If A1 = 2, then display image from ("C:\TempPic2.JPG") else
display nothing.
Does anyone have any suggestions on how to do it for Excel 2003?
Thanks in advance for any suggestions
Eric

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myPic As Object
If Target.Address = "$A$1" Then
If Range("A1") = 1 Then
Set myPic = ActiveSheet.Pictures.Insert("C:\TempPic.JPG")
Else
Set myPic = ActiveSheet.Pictures(1)
myPic.Delete
End If
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default How to edit the code to insert more than 1 image?

Try

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myPic As Object
If Target.Address = "$A$1" Then
On Error Resume Next
Set myPic = ActiveSheet.Pictures(1)
On Error GoTo 0
If Not myPic Is Nothing Then myPic.Delete

If Range("A1") = 1 Then
ActiveSheet.Pictures.Insert ("C:\TempPic.JPG")
Else
ActiveSheet.Pictures.Insert ("C:\TempPic2.JPG")
End If

End If
End Sub

--
Jacob


"Eric" wrote:

Does anyone have any suggestions on how to edit the following code to insert
more than 1 image?
If A1 = 1, then display image from ("C:\TempPic.JPG"), else
If A1 = 2, then display image from ("C:\TempPic2.JPG") else
display nothing.
Does anyone have any suggestions on how to do it for Excel 2003?
Thanks in advance for any suggestions
Eric

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myPic As Object
If Target.Address = "$A$1" Then
If Range("A1") = 1 Then
Set myPic = ActiveSheet.Pictures.Insert("C:\TempPic.JPG")
Else
Set myPic = ActiveSheet.Pictures(1)
myPic.Delete
End If
End If
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to edit the code to insert more than 1 image?

Thank you very much for suggestions
Do you have any suggestions on how to set the location to display image?
Thank you very much for suggestions
Eric

"Jacob Skaria" wrote:

Try

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myPic As Object
If Target.Address = "$A$1" Then
On Error Resume Next
Set myPic = ActiveSheet.Pictures(1)
On Error GoTo 0
If Not myPic Is Nothing Then myPic.Delete

If Range("A1") = 1 Then
ActiveSheet.Pictures.Insert ("C:\TempPic.JPG")
Else
ActiveSheet.Pictures.Insert ("C:\TempPic2.JPG")
End If

End If
End Sub

--
Jacob


"Eric" wrote:

Does anyone have any suggestions on how to edit the following code to insert
more than 1 image?
If A1 = 1, then display image from ("C:\TempPic.JPG"), else
If A1 = 2, then display image from ("C:\TempPic2.JPG") else
display nothing.
Does anyone have any suggestions on how to do it for Excel 2003?
Thanks in advance for any suggestions
Eric

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myPic As Object
If Target.Address = "$A$1" Then
If Range("A1") = 1 Then
Set myPic = ActiveSheet.Pictures.Insert("C:\TempPic.JPG")
Else
Set myPic = ActiveSheet.Pictures(1)
myPic.Delete
End If
End If
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
edit ribbon image ? Rolando Excel Programming 3 May 2nd 09 08:46 PM
Edit Button image Will[_14_] Excel Programming 2 November 12th 08 09:26 PM
Calling Edit Buttom Image? M. Authement Excel Programming 8 September 27th 05 02:15 PM
image edit control JT[_2_] Excel Programming 0 September 21st 04 11:25 PM
Image Edit and WebBrowser controls JT[_2_] Excel Programming 0 September 17th 04 06:54 PM


All times are GMT +1. The time now is 09:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"