Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Images off of a worksheet

Is there a way yet on how to pull (or put for that matter) an image tha
is on a worksheet to a userform in excel VB?

I have an image that maybe changed from time to time, but when you pul
up the file, the image should be there, I have the image on th
worksheet in A1 then B1 I have First Name C1 Last Name etc.. I ca
populate everything but the picture.

Help!

Thanks in advance!

Joe Der

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Images off of a worksheet

it would be fairly complex. You can look at Stephen Bullen's site

http://www.bmsltd.ie

go to the Excel page and find the pastepicture.zip file which contains a
workbook with sample code.

--
Regards,
Tom Ogilvy

"joederr " wrote in message
...
Is there a way yet on how to pull (or put for that matter) an image that
is on a worksheet to a userform in excel VB?

I have an image that maybe changed from time to time, but when you pull
up the file, the image should be there, I have the image on the
worksheet in A1 then B1 I have First Name C1 Last Name etc.. I can
populate everything but the picture.

Help!

Thanks in advance!

Joe Derr


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Images off of a worksheet

Hi joederr;
Can be as follows:

Option Explicit
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(8) As Byte
End Type

Private Type PICTDESC
cbSize As Long
picType As Long
hImage As Long
End Type

Private Declare Function OpenClipboard& Lib "user32" (ByVal hwnd As Long)
Private Declare Function GetClipboardData& Lib "user32" (ByVal wFormat%)
Private Declare Function CloseClipboard& Lib "user32" ()
Private Declare Function CopyImage& Lib "user32" (ByVal handle& _
, ByVal un1&, ByVal n1&, ByVal n2&, ByVal un2&)
Private Declare Function IIDFromString Lib "ole32" (ByVal lpsz As String _
, ByRef lpiid As GUID) As Long
Private Declare Function OleCreatePictureIndirect Lib "olepro32" _
(pPictDesc As PICTDESC, ByRef riid As GUID, ByVal fOwn As Long _
, ByRef ppvObj As IPicture) As Long

' picTypeConstants:
' None = 0 / Bitmap = 1 / Metafile = 2 / Icon = 3 / EMetafile = 4
Sub CopyImgToForm()
ThisWorkbook.Sheets(1).Shapes(1).CopyPicture xlScreen, xlBitmap
Dim hCopy&
OpenClipboard 0&
hCopy = CopyImage(GetClipboardData(2), 0, 0, 0, &H4)
CloseClipboard
If hCopy = 0 Then Exit Sub
Const IPictureIID = "{7BF80981-BF32-101A-8BBB-00AA00300CAB}"
Dim iPic As IPicture, tIID As GUID, tPICTDEST As PICTDESC, Ret&
Ret = IIDFromString(StrConv(IPictureIID, vbUnicode), tIID)
If Ret Then Exit Sub
With tPICTDEST
.cbSize = Len(tPICTDEST)
.picType = 1
.hImage = hCopy
End With
Ret = OleCreatePictureIndirect(tPICTDEST, tIID, 1, iPic)
If Ret Then Exit Sub
UserForm1.Picture = iPic
'UserForm1.Image1.Picture = IPic
Set iPic = Nothing
UserForm1.Show
End Sub

MP

"joederr " a écrit dans le message de
...
Is there a way yet on how to pull (or put for that matter) an image that
is on a worksheet to a userform in excel VB?

I have an image that maybe changed from time to time, but when you pull
up the file, the image should be there, I have the image on the
worksheet in A1 then B1 I have First Name C1 Last Name etc.. I can
populate everything but the picture.

Help!

Thanks in advance!

Joe Derr


---
Message posted from http://www.ExcelForum.com/



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
Images in embedded worksheet do not print correctly Glendino Excel Discussion (Misc queries) 0 November 9th 09 03:26 PM
Chart.Export images are shrinking as I export more images Jared Charts and Charting in Excel 3 January 29th 08 03:23 AM
insert images in a protected worksheet kub Excel Worksheet Functions 10 July 28th 07 11:31 AM
display images on the worksheet? vmorgan Excel Discussion (Misc queries) 3 March 17th 06 02:44 PM
Saving GIF images from worksheet using VBA Sorby Excel Programming 4 November 17th 03 09:07 PM


All times are GMT +1. The time now is 05:36 AM.

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"