Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Images in embedded worksheet do not print correctly | Excel Discussion (Misc queries) | |||
Chart.Export images are shrinking as I export more images | Charts and Charting in Excel | |||
insert images in a protected worksheet | Excel Worksheet Functions | |||
display images on the worksheet? | Excel Discussion (Misc queries) | |||
Saving GIF images from worksheet using VBA | Excel Programming |