- Katılım
- 11 Mart 2005
- Mesajlar
- 3,201
- Excel Vers. ve Dili
- Office 2013 İngilizce
DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Arkadaşlar tekrar merhaba,Merhaba,
"C:\Temp\"
klasörü altında isimlendirilmiş jpeg resimler mevcut,
Ekli dosyada "A" sütununda yazılmış dosya adlarına (*.jpg) göre B sütununa formül yoluyla gelmesi,
teşekkürler,
iyi Çalışmalar.
Option Explicit
Function K_PICTURE(File_Path As String, _
Optional Picture_Name As Variant = "", _
Optional Picture_Size As Byte = 0, _
Optional Picture_Height As Double = 100, _
Optional Picture_Width As Double = 100)
Dim My_Picture As Variant, Rng As Range
Application.ScreenUpdating = False
Application.Volatile True
Set Rng = Range(Application.Caller.Address)
For Each My_Picture In Sheets(Application.Caller.Parent.Name).Shapes
If TypeName(My_Picture.OLEFormat.Object) = "Picture" Then
If Not Intersect(My_Picture.TopLeftCell, Rng) Is Nothing Then
My_Picture.Delete
End If
End If
Next
Set My_Picture = ActiveSheet.Pictures.Insert(File_Path)
With My_Picture
.Name = IIf(Picture_Name <> "", Picture_Name, .Name)
Select Case Picture_Size
Case 0
.ShapeRange.LockAspectRatio = msoTrue
.Height = Rng.Offset(0, 0).MergeArea.Height
.Top = Rng.Top + Rng.Height / 2 - .Height / 2
.Left = Rng.Left + Rng.Width / 2 - .Width / 2
.Placement = xlMoveAndSize
Case 1
.ShapeRange.LockAspectRatio = msoFalse
.Height = Rng.Offset(0, 0).MergeArea.Height
.Width = Rng.Offset(0, 0).MergeArea.Width
.Top = Rng.Top
.Left = Rng.Left
.Placement = xlMoveAndSize
Case 2
.ShapeRange.LockAspectRatio = msoTrue
Case 3
.ShapeRange.LockAspectRatio = msoFalse
.Height = Picture_Height
.Width = Picture_Width
.Top = Rng.Top + Rng.Height / 2 - .Height / 2
.Left = Rng.Left + Rng.Width / 2 - .Width / 2
.Placement = xlMoveAndSize
End Select
End With
Set Rng = Nothing
Set My_Picture = Nothing
Application.ScreenUpdating = True
End Function
Sub foto_getir_1()
'' ilk olarak yüklü olan Resimleri silelim DİKKAT Sayfada olan tüm objeleri siler
ActiveSheet.DrawingObjects.Delete
''herhangi bir hata oluşursa Çıkış labelına git
On Error GoTo Çıkış:
Dim ResimDosyaYolu As String
Dim Resim As Object
For i = 2 To 74
If i > 73 Then
Exit Sub
End If
If Range("M" & i + 1).Value = "" Then
GoTo sonraki
End If
ResimDosyaYolu = ActiveWorkbook.Path & "\" & "PER_FOTO" & "\" & Range("M" & i + 1) & ".jpg"
'dosya yok ise hataya düşmemek için aşağıdaki kontrolü yapıyoruz.
If DosyaVarmi(ResimDosyaYolu) Then
ResimDosyaYolu = ActiveWorkbook.Path & "\" & "PER_FOTO" & "\" & Range("M" & i + 1) & ".jpg"
Else
ResimDosyaYolu = ActiveWorkbook.Path & "\" & "PER_FOTO" & "\yok.jpg"
End If
' 'resmi oluşturuyoruz.
Set Resim = ActiveSheet.Pictures.Insert(ResimDosyaYolu)
'Resmi boyutlandırıyoruz
With Range("A" & i)
Resim.Top = .Top + 1
Resim.Left = .Left + 1
Resim.Height = .Height + 15
Resim.Width = .Width + 17
End With
i = i + 3
sonraki:
Next i
Çıkış:
End Sub