批量将图片插入到Excel中,且自动调整图片大小以适应单元格的大小!
Excel情报局
Excel职场联盟




前言|职场实例


方案|解决步骤

Sub InsertPictures()Dim PicList() As VariantDim PicFormat As StringDim Rng As RangeDim sShape As ShapeOn Error Resume NextPicList = Application.GetOpenFilename(PicFormat, MultiSelect:=True)xColIndex = Application.ActiveCell.ColumnIf IsArray(PicList) Then xRowIndex = Application.ActiveCell.Row For lLoop = LBound(PicList) To UBound(PicList) Set Rng = Cells(xRowIndex, xColIndex) Set sShape = ActiveSheet.Shapes.AddPicture(PicList(lLoop), msoFalse, msoCTrue, Rng.Left, Rng.Top, Rng.Width, Rng.Height) xRowIndex = xRowIndex + 1 NextEnd IfEnd Sub操作步骤如下图所示:






赞 (0)
