Export Pictures Excel VBA

前端 未结 3 1965
情歌与酒
情歌与酒 2020-12-03 16:32

I\'m having trouble trying to select and export all pictures from a workbook. I only want the pictures. I need to select and save all of them as:\"Photo 1\", \"Photo 2\", \"

3条回答
  •  有刺的猬
    2020-12-03 16:55

    Ross's method works well but using the add method with Chart forces to leave the currently activated worksheet... which you may not want to do.

    In order to avoid that you could use ChartObject

    Public Sub AddChartObjects()
    
        Dim chtObj As ChartObject
    
            With ThisWorkbook.Worksheets("A")
    
                .Activate
    
                Set chtObj = .ChartObjects.Add(100, 30, 400, 250)
                chtObj.Name = "TemporaryPictureChart"
    
                'resize chart to picture size
                chtObj.Width = .Shapes("TestPicture").Width
                chtObj.Height = .Shapes("TestPicture").Height
    
                ActiveSheet.Shapes.Range(Array("TestPicture")).Select
                Selection.Copy
    
                ActiveSheet.ChartObjects("TemporaryPictureChart").Activate
                ActiveChart.Paste
    
                ActiveChart.Export Filename:="C:\TestPicture.jpg", FilterName:="jpg"
    
                chtObj.Delete
    
            End With
    
    End Sub
    

提交回复
热议问题