Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Image on userform from picture in a worksheet

Hi Group,

The code below loads a chart from a worksheet into an image in a userform.
Is it at all possible to use the some approach to load a picture inserted in
a
worksheet into the userform image?

Brgds

CG Rosén

Set CurrentChart = Sheets("Sheet1").ChartObjects(1).Chart
'Save chart as GIF
Fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
CurrentChart.Export Filename:=Fname, FilterName:="GIF"

'Show the chart
UserForm1.Image1.Picture = LoadPicture(Fname)

Kill (ThisWorkbook.Path & Application.PathSeparator & "temp.gif")

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Image on userform from picture in a worksheet

Hi Rosen

Use the below procedure to save the picture to a location and then load this
to image control.

Sub Macro()
Fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
SavePictureAs "Picture 1", Fname, "GIF"
UserForm1.Image1.Picture = LoadPicture(Fname)
End Sub

Sub SavePictureAs(strPicName As String, strFile As String, strFormat As
String)

Dim wsTemp As Worksheet, chtObj As Chart, pObj As Picture
Dim dblWidth As Double, dblHeight As Double

ActiveSheet.Shapes(strPicName).Select
Set pObj = Selection
dblWidth = pObj.Width: dblHeight = pObj.Height: pObj.Copy

Application.ScreenUpdating = False

Set chtObj = Charts.Add: Set wsTemp = Sheets.Add
chtObj.Location Whe=xlLocationAsObject, Name:=wsTemp.Name
wsTemp.Range("A1").Select

With wsTemp.ChartObjects(1)
.Top = 0
.Left = 0
.Width = dblWidth
.Height = dblHeight
.Activate
.Chart.Paste
.Interior.ColorIndex = 1
.Chart.Export FileName:=strFile, FilterName:=strFormat
End With

Application.DisplayAlerts = False: wsTemp.Delete
Application.DisplayAlerts = True: Application.ScreenUpdating = True

End Sub


If this post helps click Yes
---------------
Jacob Skaria


"CG Rosen" wrote:

Hi Group,

The code below loads a chart from a worksheet into an image in a userform.
Is it at all possible to use the some approach to load a picture inserted in
a
worksheet into the userform image?

Brgds

CG Rosn

Set CurrentChart = Sheets("Sheet1").ChartObjects(1).Chart
'Save chart as GIF
Fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
CurrentChart.Export Filename:=Fname, FilterName:="GIF"

'Show the chart
UserForm1.Image1.Picture = LoadPicture(Fname)

Kill (ThisWorkbook.Path & Application.PathSeparator & "temp.gif")

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Image on userform from picture in a worksheet

If you store your pictures in an imagelist object then you can load
the picture into the userform directly without using a temporary image
file.

The imagelist object can be part of a worksheet or it can be part of
the userform itself. In both cases the normal user won't see the
imagelist object when the design mode is switched off, respectivly
when the userform is being displayed.

Here a code snippet which uses a imagelist object that is part of a
worksheet.

Sub UpdatePic(i As Integer)
Dim ilist As ImageList
With ThisWorkbook
' load the picture from our imagelist
Set ilist = .Worksheets(COLORsheet).OLEObjects
("ImageList1").Object
With ilist.ListImages
PaletteForm.Image1.Picture = .Item(i)
End With
End With
PaletteForm.Repaint
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
Excel Image or Picture from SQL Image Data Type Sam K[_2_] Excel Programming 0 December 1st 08 11:04 PM
Getting Picture Into Image In UserForm ZipCurs Excel Programming 1 March 13th 08 05:53 PM
Add Userform Image from Cell Picture Address Corey Excel Programming 1 January 25th 08 02:16 PM
Screen flicker when changing Image.Picture source on UserForm Paul Martin Excel Programming 4 April 22nd 05 02:52 PM
userform image from picture in worksheet Doug Glancy[_5_] Excel Programming 2 November 10th 03 04:43 AM


All times are GMT +1. The time now is 08:18 PM.

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

About Us

"It's about Microsoft Excel"