Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Problem with Excel 2007 loading worksheet from explorer | Excel Discussion (Misc queries) | |||
excel loading | Excel Discussion (Misc queries) | |||
Loading excel | Excel Discussion (Misc queries) | |||
how do i open Excel program without loading a new worksheet? | Excel Discussion (Misc queries) | |||
automatic worksheet loading | Excel Worksheet Functions |