如何在excel vba上解决一些未对齐顶部和左侧的照片?

时间:2017-11-14 07:35:19

标签: excel vba excel-vba

我有这段代码可以将网站链接中的照片插入到每个单元格中:

Sub LoadPhotosIntoSpreadsheet()

'
' Create a loop to scroll through each site tab, starting at tab number 5
'
Application.ScreenUpdating = False

Dim I As Integer
Dim WS_Count As Integer

WS_Count = ActiveWorkbook.Sheets.Count

For I = 5 To WS_Count
Sheets(I).Select
'choose range of columns with internet references
Range("l6:p200").Select
'put photos in each cell that has an internet reference
For Each cel In Selection
            On Error Resume Next
            If cel <> 0 Then
             cel.Offset(0, 0).Select
            ActiveSheet.Pictures.Insert(cel.Value).Select
            Selection.Height = 350
            End If
        Next cel
Next I
Application.ScreenUpdating = True
End Sub

大多数照片都与每个细胞的左上角对齐,但有些照片完全错位。我玩过.left=cel.left.top=cel.top等,但无法将其放入我的代码中以使其成功运作。

非常感谢任何帮助!干杯。

0 个答案:

没有答案