View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
TedT TedT is offline
external usenet poster
 
Posts: 13
Default Loading a JPG into an Excel worksheet

All works fine!
Thanks a lot!
TedT

"Peter T" wrote:

Sub test()
Dim pic As Picture

On Error Resume Next
Set pic = ActiveSheet.Pictures("myPictureName")
On Error GoTo errH

If Not pic Is Nothing Then
pic.Delete
End If

Set pic = ActiveSheet.Pictures.Insert("C:\filePath\myPicture .jpg")
pic.Name = "myPictureName"

With Range("C3")
pic.Left = .Left
pic.Top = .Top
End With
'pic.Select

Exit Sub

errH:
MsgBox Err.Description

End Sub


Regards,
Peter T


"TedT" wrote in message
...
Thanks for you help, that works. But it has identified another

problem....
Clicking the button reloads the image over itself, so I need to delete the
image before loading. But the iamge's name seems to keep changing. How

can
I find out the name of the image before I try to delete it? Excel seems

to
assign an arbitrary name like "picture15" to it and the fiel name does not
seem to be used.

Thanks
TedT

"MrScience" wrote:

On Mar 9, 8:04 pm, TedT wrote:
Hi,
I have created a button on a spreadsheet that I want to load a JPG

Image
into the spreadsheet when it is clicked.

Does anyone know the VB code to do this. I can either overwrite an

existing
image of the same name if that is easier, or load it for the first

time - but
I also need to control where it loads on the sheet.

The file name is always the same - it is the result of an engineer

process
run by the spreadsheet.
Thanks
TedT

ActiveSheet.Pictures.Insert ("C:\filePath\myPicture.jpg")