- Katılım
- 3 Haziran 2017
- Mesajlar
- 797
- Excel Vers. ve Dili
- 2007, 32
- Altın Üyelik Bitiş Tarihi
- 08/06/2018
Yine de teşekkür etmek zor değil değil mi?Merhaba,
Sn. Halit3' e ait olan kod; fotoğrafı çalışma sayfasında seçili olan hücreye ekliyor. Bu kod ayrıca fotoğrafı hücrenin her iki yanına yaslayarak, yani hücre içine yerleştirerek ekliyor. Benim istediğim kodların mevcut yapısını bozmadan ilgili hatayı düzeltebilmek.
Tanımadığınız bir insan sonuçta size yardım etmeye çalışmış, ihtiyacınıza cevap olmasa bile.
Kodunuzu aşağıdaki ile değiştirince sorun düzelecektir.
Koda kırmızı kısım eklendi.
Buyrun.
Kod:
Sub InsertPicture()
Dim sPicture As String, pic As Picture
sPicture = Application.GetOpenFilename _
("Pictures (*.gif; *.jpg; *.bmp; *.tif), *.gif; *.jpg; *.bmp; *.tif", _
, "Select Picture to Import")
If Show = -1 Then Exit Sub
Adres = ActiveWindow.RangeSelection.Address
Dim Picture As Object
For Each Picture In ActiveSheet.Shapes
If TypeName(ActiveSheet.Shapes(Picture.Name).OLEFormat.Object) = "Picture" Then
yer1 = Picture.TopLeftCell.Address
yer2 = (Picture.TopLeftCell.Address & ":" & Picture.BottomRightCell.Address)
If yer1 = Adres Or yer2 = Adres Then
Picture.Delete
Exit For
End If
End If
Next Picture
[COLOR="Red"]On Error Resume Next[/COLOR]
Set pic = ActiveSheet.Pictures.Insert(sPicture)
With pic
.ShapeRange.LockAspectRatio = msoFalse
.Height = Range(Adres).Height - 4
.Width = Range(Adres).Width - 4
.Top = Range(Adres).Top + 2
.Left = Range(Adres).Left + 2
.Placement = xlMoveAndSize
End With
Set pic = Nothing
End Sub
Son düzenleme: