- Katılım
- 4 Haziran 2005
- Mesajlar
- 2,746
- Excel Vers. ve Dili
- 2010-2016
Aşağıdaki kodlar ile resimleri hücreye getirmekteyim. Yalnız resimler her biri resmin özelliğine göre değişik boyutta çıkmakta. Bu resmin boyutunu sabitleyebilir miyim.
Sub Resim_Ekleme()
Dim p As Object, t As Double, l As Double, w As Double, h As Double
Range("d1").Select
Range("d1").ClearContents
ActiveSheet.Pictures.Delete
Resimadi = LoadPicture("")
Resimadi = Range("B2").Text & ".jpg"
On Error Resume Next
Set pic = ActiveSheet.Pictures.Insert(ThisWorkbook.Path & "\FOTOLAR\" & Resimadi)
On Error GoTo 0
ResimDosya = ThisWorkbook.Path & "\FOTOLAR\" & Resimadi
For Each p In ActiveSheet.Pictures
p.Delete
Next
If Dir(ResimDosya) = "" Then
ResimDosya = ThisWorkbook.Path & "\FOTOLAR\ResimYok.jpg"
Set p = ActiveSheet.Pictures.Insert(ResimDosya)
Else
Set p = ActiveSheet.Pictures.Insert(ResimDosya)
End If
Set Rng = ActiveCell
With Range("d1") 'Cells(Target.Row, Target.Column - 2)
t = .Top
l = .Left
w = 120 '.Width '.Offset(0, .Columns.Count).Left - .Left
h = 120 '.Height '.Offset(.Rows.Count, 0).Top - .Top
End With
With p
.Top = t
.Left = l
.Width = 120 'w
.Height = 120 ' h
End With
Set p = Nothing
End Sub
Sub Resim_Ekleme()
Dim p As Object, t As Double, l As Double, w As Double, h As Double
Range("d1").Select
Range("d1").ClearContents
ActiveSheet.Pictures.Delete
Resimadi = LoadPicture("")
Resimadi = Range("B2").Text & ".jpg"
On Error Resume Next
Set pic = ActiveSheet.Pictures.Insert(ThisWorkbook.Path & "\FOTOLAR\" & Resimadi)
On Error GoTo 0
ResimDosya = ThisWorkbook.Path & "\FOTOLAR\" & Resimadi
For Each p In ActiveSheet.Pictures
p.Delete
Next
If Dir(ResimDosya) = "" Then
ResimDosya = ThisWorkbook.Path & "\FOTOLAR\ResimYok.jpg"
Set p = ActiveSheet.Pictures.Insert(ResimDosya)
Else
Set p = ActiveSheet.Pictures.Insert(ResimDosya)
End If
Set Rng = ActiveCell
With Range("d1") 'Cells(Target.Row, Target.Column - 2)
t = .Top
l = .Left
w = 120 '.Width '.Offset(0, .Columns.Count).Left - .Left
h = 120 '.Height '.Offset(.Rows.Count, 0).Top - .Top
End With
With p
.Top = t
.Left = l
.Width = 120 'w
.Height = 120 ' h
End With
Set p = Nothing
End Sub
