Çalışma sayfasından image'a resim alma

Erdem Akdemir

Destek Ekibi
Destek Ekibi
Katılım
4 Mayıs 2007
Mesajlar
3,644
Excel Vers. ve Dili
2016 PRO TÜRKÇE-İNG. 64 BİT
Merhaba,

Ekteki userform'daki image nesnelerine,sayfadaki resimleri nasıl alabilirim.
 

Ekli dosyalar

Necdet

Moderatör
Yönetici
Katılım
4 Haziran 2005
Mesajlar
15,527
Excel Vers. ve Dili
Ofis 365 Türkçe
Merhaba,

Sayfaya resim eklemek xl dosyasının boyutunun gereğinden fazla büyümesine neden oluyor.
Neden image nesnelerine resim eklerken bir dizinden almayı düşünmüyorsunuz?
 

Erdem Akdemir

Destek Ekibi
Destek Ekibi
Katılım
4 Mayıs 2007
Mesajlar
3,644
Excel Vers. ve Dili
2016 PRO TÜRKÇE-İNG. 64 BİT
Necdet hocam merhaba,

İşyerindeki ağda çalışan bir excel programı var.Resimlerin olduğu klasöre bazı kullanıcılar giremiyor.Resimleri baska klasöre koymayada benim yetkim yok.En iyisi içinden açmak.Shape metodu var internette onu buldum ama dosyaya uyarlayamadım.
 

halit3

Uzman
Uzman
Katılım
18 Ocak 2008
Mesajlar
12,852
Excel Vers. ve Dili
2003 excell türkçe
ve
2007 excell türkçe

Ekli dosyalar

Erdem Akdemir

Destek Ekibi
Destek Ekibi
Katılım
4 Mayıs 2007
Mesajlar
3,644
Excel Vers. ve Dili
2016 PRO TÜRKÇE-İNG. 64 BİT

Erdem Akdemir

Destek Ekibi
Destek Ekibi
Katılım
4 Mayıs 2007
Mesajlar
3,644
Excel Vers. ve Dili
2016 PRO TÜRKÇE-İNG. 64 BİT
Herkese selamlar,

Object reqired hatası alıyorum,nasıl düzeltmem gerekir.

Kod:
Private Sub CommandButton1_Click() 
  
    ActiveSheet.Shapes("Resim 2").Select 
    ActiveSheet.Shapes("Resim 2").CopyPicture 
    Me.Image1.Picture = PastePicture     
       
End Sub
 

halit3

Uzman
Uzman
Katılım
18 Ocak 2008
Mesajlar
12,852
Excel Vers. ve Dili
2003 excell türkçe
ve
2007 excell türkçe
Herkese selamlar,

Object reqired hatası alıyorum,nasıl düzeltmem gerekir.

Kod:
Private Sub CommandButton1_Click() 
  
    ActiveSheet.Shapes("Resim 2").Select 
    ActiveSheet.Shapes("Resim 2").CopyPicture 
    Me.Image1.Picture = PastePicture     
       
End Sub
birde bu dosyaya bak
iki adet userform var irdeleyiniz.
 

Ekli dosyalar

Erdem Akdemir

Destek Ekibi
Destek Ekibi
Katılım
4 Mayıs 2007
Mesajlar
3,644
Excel Vers. ve Dili
2016 PRO TÜRKÇE-İNG. 64 BİT
Halit hocam yardımlarınız için çok teşekkür ederim.

Benim bilgisayarda 64-bit 2013 ofis kurulu, verdiğiniz kodların dll dosyalarını bulamıyor. Bende bu işin peşini bıraktım. Excel dosyamdaki image'ları sildim. Dosyaya görsellik katıyordu ama çalışmadıktan sonra silmekten başka çare kalmadı. Yurtdışı sitelerinde de bu konuda hiç kaynak bulamadım desem yeridir. Excel web.tr'nin eski sürümünde bir mesaj yakaladım. Pastepicture'ı ayrı bir modülde yapmanız gerek falan diyor ama onuda anlamadım açıkçası.

http://www.excel.web.tr/archive/index.php/t-6970.html
 

Korhan Ayhan

Administrator
Yönetici
Admin
Katılım
15 Mart 2005
Mesajlar
43,008
Excel Vers. ve Dili
Microsoft 365 Tr-En 64 Bit
Ekteki örnek dosyayı inceleyiniz.
 

Ekli dosyalar

Erdem Akdemir

Destek Ekibi
Destek Ekibi
Katılım
4 Mayıs 2007
Mesajlar
3,644
Excel Vers. ve Dili
2016 PRO TÜRKÇE-İNG. 64 BİT
Korhan bey elinize bilginize sağlık. Yurtdışında bile böyle bir kod yok :)

Biraz kodu anlatsanız çok mu olurum :biggrin:
 

Korhan Ayhan

Administrator
Yönetici
Admin
Katılım
15 Mart 2005
Mesajlar
43,008
Excel Vers. ve Dili
Microsoft 365 Tr-En 64 Bit
Aslında çok kaynak var. Sadece doğru ifadeleri aramak önem kazanıyor.

Kodun yaptığı işlem;

İlgili sayfadaki nesneleri döngüye alıyor.
Resim olanlar üzerinde işlem yapılıyor.
Eğer ilgili nesne resimse dosyanıza boş bir grafik sayfası ekliyor.
Daha sonra döngüye aldığı nesneyi kopyalayıp grafik nesnesine yapıştırıyor.
Grafik nesnesinin export özelliği kullanılarak resim tanımlanan yola "jpg" formatında kayıt ediliyor.
Kayıt edilen resim dosyası form üzerindeki image nesnesine yükleniyor.
Son olarak yüklenen resim ilgili yoldan silinerek gereksiz dosya kalabalıklığı önlenmiş oluyor.

Bu döngü sayfadaki tüm resimler bitene kadar devam ediyor.

Döngüde hata oluşmaması için sayfadaki resim sayınız kadar formunuzda image nesnesi olması gerekiyor. Aksi halde kod hata verecektir.
 
Katılım
3 Haziran 2017
Mesajlar
797
Excel Vers. ve Dili
2007, 32
Altın Üyelik Bitiş Tarihi
08/06/2018
Aslında çok kaynak var. Sadece doğru ifadeleri aramak önem kazanıyor.

Kodun yaptığı işlem;

İlgili sayfadaki nesneleri döngüye alıyor.
Resim olanlar üzerinde işlem yapılıyor.
Eğer ilgili nesne resimse dosyanıza boş bir grafik sayfası ekliyor.
Daha sonra döngüye aldığı nesneyi kopyalayıp grafik nesnesine yapıştırıyor.
Grafik nesnesinin export özelliği kullanılarak resim tanımlanan yola "jpg" formatında kayıt ediliyor.
Kayıt edilen resim dosyası form üzerindeki image nesnesine yükleniyor.
Son olarak yüklenen resim ilgili yoldan silinerek gereksiz dosya kalabalıklığı önlenmiş oluyor.

Bu döngü sayfadaki tüm resimler bitene kadar devam ediyor.

Döngüde hata oluşmaması için sayfadaki resim sayınız kadar formunuzda image nesnesi olması gerekiyor. Aksi halde kod hata verecektir.

Korhan Hocam,

Bu yöntem benim çalışmam için pek kullanışlı değil. Çünkü sayfamda onlarca resim ama userformda sadece bir tane image nesnesi var.

Yapmak istediğim şey şu: Sayfaya resimleri userform ile alıyorum. Bu aktarma işleminde resimler sırayla "Resim 1", "Resim 2" diye isim alıyor. Ben bu resimleri tekrar userforma almak istiyorum.

A-I sütunlarını kullanıyorum. A-G de metinler var, bunları userforma aktarıyorum ancak aynı satırın I sütunundaki resmi çağırmak için bir kod bulamadım.

Metinleri aktarmak için kullandığım kod aşağıda.

Yardımınız için şimdiden teşekkürler.

Selam ve saygılarımla.

Kod:
Private Sub CommandButton3_Click()


        If TextBox8.Text <> "" Then
           
                        Son_Dolu_Satir = Sheets("liste").Range("A65536").End(3).Row
                        If WorksheetFunction.CountIf(Sheets("liste").Range("B1:B" & Son_Dolu_Satir), TextBox8.Text) > 0 Then
MsgBox "Bu resim adıyla bir resim atıldı", vbCritical
GoTo 20
End If
                        Bos_Satir = Son_Dolu_Satir + 1
                        Sheets("liste").Range("A" & Bos_Satir).Value = _
                                             Application.WorksheetFunction.Max(Sheets("liste").Range("A:A")) + 1
                                             
                       
                        
                        
                        Sheets("liste").Range("A" & Bos_Satir).Value = ComboBox2.Text
                       
                        Sheets("liste").Range("B" & Bos_Satir).Value = TextBox8.Text
                        Sheets("liste").Range("C" & Bos_Satir).Value = TextBox9.Text
                        Sheets("liste").Range("D" & Bos_Satir).Value = TextBox10.Text
                        Sheets("liste").Range("E" & Bos_Satir).Value = TextBox11.Text
                        Sheets("liste").Range("F" & Bos_Satir).Value = TextBox12.Text
                        Sheets("liste").Range("G" & Bos_Satir).Value = TextBox13.Text
                        Sheets("liste").Range("H" & Bos_Satir).Value = TextBox14.Text
                        
                        Sheets("liste").Pictures.Insert(resim_adi).Select
                        Selection.Top = Range("I" & Bos_Satir).Top: Selection.Left = Range("I" & Bos_Satir).Left
                        Selection.ShapeRange.LockAspectRatio = msoFalse: Selection.ShapeRange.Height = 200: Selection.ShapeRange.Width = 293
                        ActiveCell.Select
                        
                        
                        
                        Sheets("liste").Select
                        MsgBox "Görsel havuza atıldı.", vbInformation, "Yeni bir soru ekleyebilirsiniz."
                        
                        For i = 8 To 14
Controls("TextBox" & i).Value = ""


Next i

                Else
                    GoTo 5
                End If
            
    Exit Sub
5
    MsgBox "İstenen verileri eksiksiz girdiğinizden emin olduktan sonra tekrar deneyiniz.", vbExclamation, "Kontrol"
20:


End Sub
 
Katılım
3 Haziran 2017
Mesajlar
797
Excel Vers. ve Dili
2007, 32
Altın Üyelik Bitiş Tarihi
08/06/2018

Halit Bey,

Çok teşekkür ederim. Uzun uzun cevap yazmışsınız, elinize sağlık.

Uzun uğraşlar ve yardımlarınız sayesinde istediğim resmi, yukarıda paylaştığım kod ile, istediğim boyutta sayfaya atmayı başardım.

Aşağıdaki kod ile listboxta seçtiğim satırı, resimle beraber userforma çağırıyorum. Ancak metinler geliyor, resim gelmiyor. Yani aşağıdaki koda I sütunundaki resmin, userformdaki Image1 nesnesine getirecek kod eksik.

Kod:
Private Sub CheckBox6_Click()

Dim k As Range, sonsat As Long
Sheets("liste").Select
sonsat = Cells(Rows.Count, "B").End(xlUp).Row
Set k = Range("B2:B" & sonsat).Find(ListBox1.Column(1), , xlValues, xlWhole)
If Not k Is Nothing Then

    Range("A" & k.Row & ":I" & k.Row).Select
    
    
    UserForm3.TextBox47.Text = Cells(ActiveCell.Row, "b")
    UserForm3.TextBox48.Text = Cells(ActiveCell.Row, "c")
    UserForm3.TextBox49.Text = Cells(ActiveCell.Row, "d")
    UserForm3.TextBox50.Text = Cells(ActiveCell.Row, "e")
    UserForm3.TextBox51.Text = Cells(ActiveCell.Row, "f")
    UserForm3.TextBox52.Text = Cells(ActiveCell.Row, "g")
    UserForm3.TextBox53.Text = Cells(ActiveCell.Row, "h")
    
    
End If
End Sub
Sizi çok uğraştırdım, kusura bakmayın lütfen.
 
Katılım
3 Haziran 2017
Mesajlar
797
Excel Vers. ve Dili
2007, 32
Altın Üyelik Bitiş Tarihi
08/06/2018
Özetle:

Aşağıdaki kodu tersine işlem yapacak şekilde revize etmek istiyorum.
Userform üzerindeki listeden seçim yaparak.

Kod:
                        Sheets("liste").Pictures.Insert(resim_adi).Select
                        Selection.Top = Range("I" & Bos_Satir).Top: Selection.Left = Range("I" & Bos_Satir).Left
                        Selection.ShapeRange.LockAspectRatio = msoFalse: Selection.ShapeRange.Height = 200: Selection.ShapeRange.Width = 293
                        ActiveCell.Select
 

halit3

Uzman
Uzman
Katılım
18 Ocak 2008
Mesajlar
12,852
Excel Vers. ve Dili
2003 excell türkçe
ve
2007 excell türkçe
Halit Bey,

Çok teşekkür ederim. Uzun uzun cevap yazmışsınız, elinize sağlık.

Uzun uğraşlar ve yardımlarınız sayesinde istediğim resmi, yukarıda paylaştığım kod ile, istediğim boyutta sayfaya atmayı başardım.

Aşağıdaki kod ile listboxta seçtiğim satırı, resimle beraber userforma çağırıyorum. Ancak metinler geliyor, resim gelmiyor. Yani aşağıdaki koda I sütunundaki resmin, userformdaki Image1 nesnesine getirecek kod eksik.

Kod:
Private Sub CheckBox6_Click()

Dim k As Range, sonsat As Long
Sheets("liste").Select
sonsat = Cells(Rows.Count, "B").End(xlUp).Row
Set k = Range("B2:B" & sonsat).Find(ListBox1.Column(1), , xlValues, xlWhole)
If Not k Is Nothing Then

    Range("A" & k.Row & ":I" & k.Row).Select
    
    
    UserForm3.TextBox47.Text = Cells(ActiveCell.Row, "b")
    UserForm3.TextBox48.Text = Cells(ActiveCell.Row, "c")
    UserForm3.TextBox49.Text = Cells(ActiveCell.Row, "d")
    UserForm3.TextBox50.Text = Cells(ActiveCell.Row, "e")
    UserForm3.TextBox51.Text = Cells(ActiveCell.Row, "f")
    UserForm3.TextBox52.Text = Cells(ActiveCell.Row, "g")
    UserForm3.TextBox53.Text = Cells(ActiveCell.Row, "h")
    
    
End If
End Sub
Sizi çok uğraştırdım, kusura bakmayın lütfen.
Bu sorunuz doğrultusunda dosyanızın küçük bir örneğini ekleyin listbox ın nasıl çalıştığına bir bakalım

Ayrıca dosyanızda resim olsun ki ne yaptığımızı görelim.
 
Katılım
3 Haziran 2017
Mesajlar
797
Excel Vers. ve Dili
2007, 32
Altın Üyelik Bitiş Tarihi
08/06/2018
Bu sorunuz doğrultusunda dosyanızın küçük bir örneğini ekleyin listbox ın nasıl çalıştığına bir bakalım

Ayrıca dosyanızda resim olsun ki ne yaptığımızı görelim.
İlginiz için tekrar teşekkür ediyorum.

Örnek dosya ektedir.

Selam ve saygılarımla.
 

Ekli dosyalar

halit3

Uzman
Uzman
Katılım
18 Ocak 2008
Mesajlar
12,852
Excel Vers. ve Dili
2003 excell türkçe
ve
2007 excell türkçe
İlginiz için tekrar teşekkür ediyorum.

Örnek dosya ektedir.

Selam ve saygılarımla.
Cevapları çok geç yazıyorsunuz ben sizin sorunuzu baya geç hatırladım

bu kodu bir modülün içine yapıştırın.

Kod:
Option Explicit
Option Compare Text

#If Win64 Then
Private Declare PtrSafe Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Integer) As Long
Private Declare PtrSafe Function OpenClipboard Lib "user32" (ByVal hWnd As Long) As Long
Private Declare PtrSafe Function GetClipboardData Lib "user32" (ByVal wFormat As Integer) As Long
Private Declare PtrSafe Function CloseClipboard Lib "user32" () As Long
Private Declare PtrSafe Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As uPicDesc, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
Private Declare PtrSafe Function CopyEnhMetaFile Lib "gdi32" Alias "CopyEnhMetaFileA" (ByVal hemfSrc As Long, ByVal lpszFile As String) As Long
Private Declare PtrSafe Function CopyImage Lib "user32" (ByVal handle As Long, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
#Else
Private Declare Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Integer) As Long
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Integer) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As uPicDesc, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
Private Declare Function CopyEnhMetaFile Lib "gdi32" Alias "CopyEnhMetaFileA" (ByVal hemfSrc As Long, ByVal lpszFile As String) As Long
Private Declare Function CopyImage Lib "user32" (ByVal handle As Long, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long

#End If

#If VBA7 Then
#Else
#End If


Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type

Private Type uPicDesc
Size As Long
Type As Long
hPic As Long
hPal As Long
End Type

Const CF_BITMAP = 2


Function PastePicture(Optional lXlPicType As Long = xlPicture) As IPicture

Dim h As Long, hPicAvail As Long, hPtr As Long, hPal As Long, lPicType As Long, hCopy As Long
lPicType = IIf(lXlPicType = xlBitmap, CF_BITMAP, 14)
hPicAvail = IsClipboardFormatAvailable(lPicType)
If hPicAvail <> 0 Then
h = OpenClipboard(0&)
If h > 0 Then
hPtr = GetClipboardData(lPicType)
If lPicType = CF_BITMAP Then
hCopy = CopyImage(hPtr, 0, 0, 0, 4)
Else
hCopy = CopyEnhMetaFile(hPtr, vbNullString)
End If
h = CloseClipboard
If hPtr <> 0 Then Set PastePicture = CreatePicture(hCopy, 0, lPicType)
End If
End If

End Function

Private Function CreatePicture(ByVal hPic As Long, ByVal hPal As Long, ByVal lPicType) As IPicture
Dim r As Long, uPicInfo As uPicDesc, IID_IDispatch As GUID, IPic As IPicture

With IID_IDispatch
.Data1 = &H7BF80980
.Data2 = &HBF32
.Data3 = &H101A
.Data4(0) = &H8B
.Data4(1) = &HBB
.Data4(2) = &H0
.Data4(3) = &HAA
.Data4(4) = &H0
.Data4(5) = &H30
.Data4(6) = &HC
.Data4(7) = &HAB
End With
With uPicInfo
.Size = Len(uPicInfo)
.Type = IIf(lPicType = CF_BITMAP, 1, 4)
.hPic = hPic
.hPal = IIf(lPicType = CF_BITMAP, hPal, 0)
End With

r = OleCreatePictureIndirect(uPicInfo, IID_IDispatch, True, IPic)
'If r <> 0 Then Debug.Print "Create Picture: " & fnOLEError(r)
Set CreatePicture = IPic

End Function
ListBox1_Click

ait kod

Kod:
Private Sub ListBox1_Click()


Set S1 = Worksheets("sayfa1")

a = ListBox1.ListIndex + 2

Adres = Worksheets("sayfa1").Cells(a, 1).Address
Dim Picture As Object
For Each Picture In S1.Shapes

If TypeName(S1.Shapes(Picture.Name).OLEFormat.Object) = "Picture" Then
yer = S1.Cells(Picture.BottomRightCell.Row, Picture.BottomRightCell.Column).Address

If yer = Adres Then
sut = Picture.BottomRightCell.Row

S1.Shapes(Picture.Name).Select
S1.Shapes(Picture.Name).CopyPicture

UserForm2.Image1.Picture = PastePicture
UserForm2.TextBox7.Text = Cells(sut, "h")
UserForm2.TextBox2.Text = Cells(sut, "c")
UserForm2.TextBox3.Text = Cells(sut, "d")
UserForm2.TextBox4.Text = Cells(sut, "e")
UserForm2.TextBox5.Text = Cells(sut, "f")
UserForm2.TextBox6.Text = Cells(sut, "g")

Exit For
End If
End If

Next Picture
UserForm2.Show

End Sub
 
Katılım
3 Haziran 2017
Mesajlar
797
Excel Vers. ve Dili
2007, 32
Altın Üyelik Bitiş Tarihi
08/06/2018
Cevapları çok geç yazıyorsunuz ben sizin sorunuzu baya geç hatırladım

bu kodu bir modülün içine yapıştırın.

Kod:
Option Explicit
Option Compare Text

#If Win64 Then
Private Declare PtrSafe Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Integer) As Long
Private Declare PtrSafe Function OpenClipboard Lib "user32" (ByVal hWnd As Long) As Long
Private Declare PtrSafe Function GetClipboardData Lib "user32" (ByVal wFormat As Integer) As Long
Private Declare PtrSafe Function CloseClipboard Lib "user32" () As Long
Private Declare PtrSafe Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As uPicDesc, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
Private Declare PtrSafe Function CopyEnhMetaFile Lib "gdi32" Alias "CopyEnhMetaFileA" (ByVal hemfSrc As Long, ByVal lpszFile As String) As Long
Private Declare PtrSafe Function CopyImage Lib "user32" (ByVal handle As Long, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
#Else
Private Declare Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Integer) As Long
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Integer) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As uPicDesc, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
Private Declare Function CopyEnhMetaFile Lib "gdi32" Alias "CopyEnhMetaFileA" (ByVal hemfSrc As Long, ByVal lpszFile As String) As Long
Private Declare Function CopyImage Lib "user32" (ByVal handle As Long, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long

#End If

#If VBA7 Then
#Else
#End If


Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type

Private Type uPicDesc
Size As Long
Type As Long
hPic As Long
hPal As Long
End Type

Const CF_BITMAP = 2


Function PastePicture(Optional lXlPicType As Long = xlPicture) As IPicture

Dim h As Long, hPicAvail As Long, hPtr As Long, hPal As Long, lPicType As Long, hCopy As Long
lPicType = IIf(lXlPicType = xlBitmap, CF_BITMAP, 14)
hPicAvail = IsClipboardFormatAvailable(lPicType)
If hPicAvail <> 0 Then
h = OpenClipboard(0&)
If h > 0 Then
hPtr = GetClipboardData(lPicType)
If lPicType = CF_BITMAP Then
hCopy = CopyImage(hPtr, 0, 0, 0, 4)
Else
hCopy = CopyEnhMetaFile(hPtr, vbNullString)
End If
h = CloseClipboard
If hPtr <> 0 Then Set PastePicture = CreatePicture(hCopy, 0, lPicType)
End If
End If

End Function

Private Function CreatePicture(ByVal hPic As Long, ByVal hPal As Long, ByVal lPicType) As IPicture
Dim r As Long, uPicInfo As uPicDesc, IID_IDispatch As GUID, IPic As IPicture

With IID_IDispatch
.Data1 = &H7BF80980
.Data2 = &HBF32
.Data3 = &H101A
.Data4(0) = &H8B
.Data4(1) = &HBB
.Data4(2) = &H0
.Data4(3) = &HAA
.Data4(4) = &H0
.Data4(5) = &H30
.Data4(6) = &HC
.Data4(7) = &HAB
End With
With uPicInfo
.Size = Len(uPicInfo)
.Type = IIf(lPicType = CF_BITMAP, 1, 4)
.hPic = hPic
.hPal = IIf(lPicType = CF_BITMAP, hPal, 0)
End With

r = OleCreatePictureIndirect(uPicInfo, IID_IDispatch, True, IPic)
'If r <> 0 Then Debug.Print "Create Picture: " & fnOLEError(r)
Set CreatePicture = IPic

End Function
ListBox1_Click

ait kod

Kod:
Private Sub ListBox1_Click()


Set S1 = Worksheets("sayfa1")

a = ListBox1.ListIndex + 2

Adres = Worksheets("sayfa1").Cells(a, 1).Address
Dim Picture As Object
For Each Picture In S1.Shapes

If TypeName(S1.Shapes(Picture.Name).OLEFormat.Object) = "Picture" Then
yer = S1.Cells(Picture.BottomRightCell.Row, Picture.BottomRightCell.Column).Address

If yer = Adres Then
sut = Picture.BottomRightCell.Row

S1.Shapes(Picture.Name).Select
S1.Shapes(Picture.Name).CopyPicture

UserForm2.Image1.Picture = PastePicture
UserForm2.TextBox7.Text = Cells(sut, "h")
UserForm2.TextBox2.Text = Cells(sut, "c")
UserForm2.TextBox3.Text = Cells(sut, "d")
UserForm2.TextBox4.Text = Cells(sut, "e")
UserForm2.TextBox5.Text = Cells(sut, "f")
UserForm2.TextBox6.Text = Cells(sut, "g")

Exit For
End If
End If

Next Picture
UserForm2.Show

End Sub

Sorunsuz çalışıyor hocam. Çok ama çok teşekkürler.
Gecikme için de özür dilerim.
 
Üst