Excel 기술, 대량 가져오기 내보내기 그림 VBA

1613 단어 Excel
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 For
Next


End 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

좋은 웹페이지 즐겨찾기