Excel批量插入学籍照片的宏代码

时间:2022-04-08 08:30:05 阅读: 最新文章 文档下载
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。
Excel批量插入学籍照片的宏代码

Sub InsertPic() On Error Resume Next Sheets(1).Select Sheets(1).Delete

Sheets("照片").Select

Sheets("照片").Copy Before:=Sheets("照片") Cells.Select Range("A2").Activate Selection.Copy Selection.PasteSpecial Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Sheets("照片 (2)").Select Sheets("照片 (2)").Name = 1

Sheets("1").Select sPath = "d:\pic\"

Application.ScreenUpdating = False

With ThisWorkbook.Sheets("1") 'i = 3

Paste:=xlPasteValues,


'x = 1

For i = 3 To Int(Range("b2") / 6) * 2 + 3 Step 2 For x = 1 To 6 If .Cells(i, x) <> "" Then

sfileName = sPath & .Cells(i, x) Cells(i, x).Select

ActiveSheet.Pictures.Insert(sfileName).Select Selection.ShapeRange.ScaleHeight 1.5, msoFalse, msoScaleFromTopLeft

Selection.ShapeRange.IncrementLeft 1.2 Selection.ShapeRange.IncrementTop 1.2

If Err <> 0 Then

'MsgBox .Cells(i, x) & "不存在"

sfileName = sPath & "没有照片.jpg" Cells(i, x).Select




ActiveSheet.Pictures.Insert(sfileName).Select Selection.ShapeRange.ScaleHeight 1.5, msoFalse, msoScaleFromTopLeft

Selection.ShapeRange.IncrementLeft 1.2 Selection.ShapeRange.IncrementTop 1.2

Err = 0 End If End If Next x Next i End With

Application.ScreenUpdating = True End Sub


本文来源:https://www.wddqw.com/doc/091c3f511411cc7931b765ce0508763231127463.html