|
Sub 新插入图片居中()
Dim i As Integer
Dim filpath As String
Dim j As Double
Dim k As Integer
Dim m As Double
Dim rng As Range
Dim s As String
filpath = "F:\" '修改上面一行的目录地址
With ActiveSheet
y = Selection.Column - 3
filpathq = filpath & Cells(Selection.Row, Selection.Column - 1 - y).Value & ".jpg" '"-" & Chr(65 + y) &
If Dir(filpathq) <> "" Then
Set rng = .Cells(Selection.Row, Selection.Column)
.Pictures.Insert(filpathq).Select
With Selection
j = .Width / .Height
m = rng.Width / rng.Height
If j < m Then
.Height = rng.Height - 4
.Top = rng.Top + 2
.Left = rng.Left + (rng.Width - .Width) / 2
.Placement = 1
Else
.Width = rng.Width - 4
.Top = rng.Top + (rng.Height - .Height) / 2
.Left = rng.Left + 2
.Placement = 1
End If
End With
Else
s = s & Chr(10) & .Cells(i + 1, 1).Text
End If
' .Cells(1, 1).Select
End With
End Sub
|
|