|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 批量插图()
Dim mSP As Object, sH As Worksheet, mWd, mHei, mLeft, mTop, mRow, tmPStr
Dim rG As Range, mPath As String, tMp, mFile As String
' On Error Resume Next
mPath = ThisWorkbook.Path
Set sH = ActiveSheet
With sH
mRow = .Cells(.Rows.Count, "C").End(3).Row
If mRow < 2 Then Exit Sub
For i = 2 To mRow
If .Cells(i, "C") <> "" Then
tmPStr = Dir(mPath & "\" & .Cells(i, "C") & ".jpg")
If tmPStr <> "" Then
mFile = mPath & "\" & tmPStr
Set mSP = .Pictures.Insert(mFile)
With mSP
.ShapeRange.LockAspectRatio = msoFalse
.Width = sH.Range("B:B").Width - 6
.Height = sH.Rows(i).RowHeight - 6
.Top = sH.Cells(i, "B").Top + 3
.Left = sH.Cells(i, "B").Left + 3
End With
End If
End If
Next i
End With
End Sub
|
|