Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Loading a JPG into an Excel worksheet

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Loading a JPG into an Excel worksheet

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")

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Loading a JPG into an Excel worksheet

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")


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Loading a JPG into an Excel worksheet

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")




  #5   Report Post  
Posted to microsoft.public.excel.programming
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")







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
Problem with Excel 2007 loading worksheet from explorer Bob Acquaviva Excel Discussion (Misc queries) 2 June 27th 07 05:08 PM
excel loading whyrrsd Excel Discussion (Misc queries) 0 May 13th 07 08:55 AM
Loading excel Mike R Excel Discussion (Misc queries) 13 March 1st 05 07:04 PM
how do i open Excel program without loading a new worksheet? mElissA Excel Discussion (Misc queries) 4 December 31st 04 01:56 AM
automatic worksheet loading dsoelter Excel Worksheet Functions 2 December 20th 04 09:31 PM


All times are GMT +1. The time now is 07:47 AM.

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"