|
本帖最后由 26827557 于 2016-5-22 07:35 编辑
老师你好!我想根据“序号.学生姓名“来作为图片名称,批量插入图片到工作表单元格里,交较好能设置其属性。下面是段代码,能否帮我整理下
Dim a As Object
Set a = ActiveSheet.Pictures.Insert(ThisWorkbook.Path & "\学生图片\" & Range("E10") & "\" & Range("E10") & ".jpg")
a.Left = [L22].Left
a.Top = [L22].Top
a.Height = [L22:X33].Height
- Sub Macro1()
- mypath = ThisWorkbook.Path & ""
- For Each m In ActiveSheet.Shapes
- If m.Type <> 8 Then m.Delete
- Next
- For i = 3 To Range("b65536").End(xlUp).Row
- Set c = Cells(i, 6)
- zf = Cells(i, 1) & "." & Cells(i, 2)
- x = c.Left: y = c.Top
- w = c.Width: h = c.Height
- ActiveSheet.Shapes.AddShape(msoShapeRectangle, x, y, w, h).Select
- Selection.ShapeRange.Fill.UserPicture mypath & zf & ".JPG"
- Next
- [a1].Activate
- End Sub
复制代码
|
|