'fin de dézippage les VML compris
'----------------------------------------------------------
'copier les images
Dim DictShp As Object, DictFile As Object, Ccom As Object, Cel, Fname$
Set DictShp = CreateObject("Scripting.Dictionary")
Set DictFile = CreateObject("Scripting.Dictionary")
ChargerDicts drawing1VML, drawing1VMLREL, DictShp, DictFile
For Each Cel In [Tbl_Invendus[Désignation]]
Set Ccom = Cel.Comment
Select Case True
Case Ccom Is Nothing
Case Not Ccom.Shape.Fill.Type = msoFillPicture
Case Else
Fname = DictFile(DictShp(CStr(Ccom.Shape.id)))
FileCopy DestFolderimage & "\" & Fname, _
DestFolderimage & "\" & Cel & ".jpg"
End Select
Next
Kill DestFolderimage & "\image*.*"
Kill drawing1VMLREL
Kill drawing1VML
Set DictShp = Nothing: Set DictFile = Nothing
MsgBox "Extraction des images de commentaires terminée"
End Sub
Sub ChargerDicts(vmlFile, vmlrelFile, DictShp, DictFile)
Dim fileName$, objName, relId$, shapeId$, XmlNamespaces$
Dim FSO As Object, xmlDoc As Object, nodes As Object, node As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set xmlDoc = CreateObject("MSXML2.DOMDocument")
xmlDoc.async = False
xmlDoc.Load vmlFile
XmlNamespaces = "xmlns:v='urn:schemas-microsoft-com:vml' xmlns:o='urn:schemas-microsoft-com:office:office'"
xmlDoc.SetProperty "SelectionNamespaces", XmlNamespaces
Set nodes = xmlDoc.SelectNodes("//v:shape")
For Each node In nodes
shapeId = Right(node.getAttribute("id"), 4)
relId = node.ChildNodes(0).getAttribute("o:relid")
'Debug.Print shapeId,relId
DictShp.Add shapeId, relId
Next
xmlDoc.Load vmlrelFile
Set nodes = xmlDoc.SelectNodes("//Relationship")
For Each node In nodes
fileName = FSO.GetFileName(node.getAttribute("Target"))
relId = node.getAttribute("Id")
'Debug.Print relId, fileName
DictFile.Add relId, fileName
Next
Set FSO = Nothing: Set nodes = Nothing: Set xmlDoc = Nothing
End Sub