YasserKhalil
Well-Known Member
Hello everyone
I have a workbook that was working well and exports pictures in the sheet to the same workbook path but now I go blank pictures in the exported files
I am using office 2016 32 bit ... In the past I was using office 2013 64 bit ..
I have a workbook that was working well and exports pictures in the sheet to the same workbook path but now I go blank pictures in the exported files
Code:
Sub ExportPictures()
Dim imag_path As String, shap As Shape
Dim f_name As String, x As Integer
x = 1
imag_path = ThisWorkbook.Path
For Each shap In ActiveSheet.Shapes
If shap.Type = msoPicture Then
f_name = imag_path & "\" & x & ".jpg"
CopyPicToFile shap, f_name
x = x + 1
End If
Next shap
End Sub
Sub CopyPicToFile(aShape As Shape, aFilename As String)
Dim cht As Excel.ChartObject
Application.ScreenUpdating = False
aShape.CopyPicture xlScreen, xlPicture
Set cht = ActiveSheet.ChartObjects.Add(0, 0, aShape.Width, aShape.Height)
cht.Chart.Paste
cht.Chart.Export aFilename
cht.Delete
Application.ScreenUpdating = True
Set cht = Nothing
End Sub