当前位置: 代码迷 >> VBA >> Excel技艺,批量导入导出图片VBA
  详细解决方案

Excel技艺,批量导入导出图片VBA

热度:3238   发布时间:2013-02-26 00:00:00.0
Excel技巧,批量导入导出图片VBA
Sub save_pic()For Each p In ActiveSheet.Shapes        ph = p.Height        pw = p.Width        p.ScaleHeight 1, True        p.ScaleWidth 1, True                pn = p.TopLeftCell.Offset(0, -1).Value        Debug.Print pn, ph, pw, p.Name        p.Name = pn                p.CopyPicture        With ActiveSheet.ChartObjects.Add(0, 0, p.Width + 5, p.Height + 5).Chart            .Paste            .Export "D:\ex\" & p.Name & ".jpg", "JPG"            .Parent.Delete        End With        p.Width = pw        p.Height = ph                Exit ForNextEnd Sub

?

Sub addpic()For Each Shp In ActiveSheet.Shapes      If Shp.Type = msoPicture Then Shp.Delete  Next  i = 2  Do While Range("A" & i) <> ""  Range("B" & i).Select  Set mypic = ActiveSheet.Pictures.Insert("D:\www\pendant\" & Range("A" & i) & ".jpg")  With mypic  .ShapeRange.LockAspectRatio = msoFalse  .Top = Range("B" & i).Top + 5  .Left = Range("B" & i).Left + 5  .Height = Range("B" & i).Height - 10    .Width = Range("B" & i).Width - 10    .Placement = xlMoveAndSize  End With  i = i + 1  Loop  Set mypic = Nothing  End Sub

?

  相关解决方案