EXCEL按照行批量插入图片
1、打开excel,在“开发工具”选项卡下,打开“Visual basic” 如下图所示!
2、在 visual basic 窗口下 点击 “插入” 选择“模块”,如下图所示
3、把下面代码粘贴到模块内 :Sub 图片横排批量导入() Dim address As String Dim cellrow, picrow As Inte爿讥旌护ger On Error Resume Next '容错处理 address = "E:\商品图片\" '图片文件夹所在的位置 cellrow = 1 '设置款号所在行 picrow = 2 '设置插入图片所在第几行 Application.ScreenUpdating = False For i = 2 To Range("XFD1").End(xlToLeft).Column Cells(picrow, i).Select Cells(picrow, i) = "aa" ActiveSheet.Shapes.AddShape(msoShapeRectangle, Cells(picrow, i).Left, Cells(picrow, i).Top, Cells(picrow, i).Width, Cells(picrow, i).Height).Fill.UserPicture address & "\" & Cells(cellrow, i).Text & ".jpg" Selection.ShapeRange.LockAspectRatio = msoTrueSelection.ShapeRange.Height = 20#Selection.ShapeRange.Width = 10#Selection.ShapeRange.Rotation = 0#Selection.Placement = xlMoveAndSizeSelection.PrintObject = True Next i Application.ScreenUpdating = True End Sub需要修改代码的地方:1.图片地址位置 2.图片名称所在行 3.图片存放行 4.图片格式,代码默认是.jpg 格式,其他格式自行修改 5.保存
4、在在“开发工具”选项卡下 点击 宏 找到我们修改好的 宏模块,点击 执行 即可得到图片