PDA

View Full Version : Saving Embedded Picture From Excel Workbook Sheet To Folder Hard Drive



littleiitin
10-31-2011, 02:31 PM
Sub ExportImageinExceltoADrive(strsheetName As String, strPicName As String, strPathtoSavewithImageName As String)

Dim chtTempChart As ChartObject

With ThisWorkbook.Worksheets(strsheetName)
Set chtTempChart = .ChartObjects.Add(500, 500, 500, 350)
With chtTempChart.Chart
.ChartType = xlLine
.Location Where:=xlLocationAsObject, Name:=strsheetName
.HasLegend = False
End With
.Shapes(strPicName).Copy
chtTempChart.Activate
chtTempChart.Chart.Paste
chtTempChart.Chart.Export Filename:=strPathtoSavewithImageName, FilterName:="jpeg"
chtTempChart.Delete
End With
End Sub


Below is Example How to Use:



Sub ExportExample()

Dim strPath As String
Dim strSheet As String
Dim strPicName As String

'========Sheet Name where Image is==========================================
strSheet = "3333"
'================================================= ==========================

'=======Image Name============================================== ============
strPicName = "Picture 10"
'================================================= ==========================

'=======Path where you want to Save this Image with Image Name==============
'==============You can write any name in Place of "Background-16"===========

strPath = "K:\ExcelFox\Background-16.jpg"
'================================================= ==========================

Call ExportImageinExceltoADrive(strSheet, strPicName, strPath)
End Sub