Hi susanto
I don’t understand why you still get the problem. I have not been able to see that problem with your sample file. I do not have much experience with embedded pictures, in fact this is the first time I have seen a macro like yours, so I am probably not the best person to help
I do notice that in the folders s1_files and s2_files there are always double pictures. For each picture there is a .png and a .gif
So this next suggestion of mine is really a long shot: Before the copy is made of the .png files, you could try deleting the .gif files, like this:
Kill sTmpFolder & "\s" & i & "_files\*.gif"
Code:
Sub ExtractPictures()
Dim FSO As Object, sFolder As String, sTmpFolder As String, WB As Workbook, WS As Worksheet, i As Long
Set FSO = VBA.CreateObject("Scripting.FileSystemObject")
Set WB = ActiveWorkbook
sFolder = WB.Path & "\" & WB.Name & "_Pictures"
sTmpFolder = sFolder & "\TmpFolder"
If FSO.FolderExists(sFolder) Then
FSO.DeleteFolder sFolder
End If
FSO.CreateFolder sFolder
FSO.CreateFolder sTmpFolder
'Application.ScreenUpdating = False
For Each WS In WB.Worksheets
If WS.Pictures.Count > 0 Then
WS.Copy
i = i + 1
ActiveWorkbook.SaveAs Filename:=sTmpFolder & "\s" & i & ".htm", FileFormat:=xlHtml
Kill sTmpFolder & "\s" & i & "_files\*.gif"
FSO.CreateFolder sFolder & "\" & WS.Name
FSO.CopyFile sTmpFolder & "\s" & i & "_files\*.png", sFolder & "\" & WS.Name '
ActiveWorkbook.Close False
End If
Next
Application.ScreenUpdating = True
FSO.DeleteFolder sTmpFolder
Shell "Explorer.exe /Open,""" & sFolder & """", 1
End Sub
I am afraid I have no other ideas.
I hope someone else can help here or at mrexcel
Good luck
Alan
Bookmarks