Ciao ho questa procedura in VBA che esplora direttamente il file word\document.xml precedentemente estratto da un docx. Esiste un modo per far analizzare direttamente il file senza estarre preventivamente i file dal docx?
Grazie
codice:
Sub ElencaNodiDocumConSchema()
  ChDir ThisWorkbook.path
  'MsgBox Dir("*.xml") 'servita per debug
  Dim DocXml As DOMDocument
  Dim NodiXml As IXMLDOMNodeList, NodoXml As IXMLDOMNode
  Set DocXml = New DOMDocument
  DocXml.async = False 'inibisce sincronizzazione DOM/origine
  DocXml.Load ("word\document.xml") 'carica il docum. DOM
  'Seleziona tutti i nodi-testo, per DEBUG
  'Set NodiXml = DocXml.SelectNodes("//w:t")
  'Seleziona i nodi relativi allo schema XML Fattura
  Dim strQyery As String
  strQuery = "//w:customXml//w:customXml"
  Set NodiXml = DocXml.SelectNodes(strQuery)
  Dim NumNodiTesto As Integer
  'NumNodiTesto = NodiXml.Length 'Per DEBUG
  'MsgBox "Numero nodi-testo: " & NumNodiTesto 'Per DEBUG
  Dim TuttoIlTesto As Wo
  Dim NomeCampo As String, DatoCampo As String
  For Each NodoXml In NodiXml
    i = i + 1
    NomeCampo = NodoXml.Attributes(0).Text
    DatoCampo = NodoXml.Text
    MsgBox "Nodo N. " & i & ":" & vbLf & _
    NomeCampo & " = " & DatoCampo
    TuttoIlTesto = TuttoIlTesto & " " & DatoCampo
  Next
  MsgBox TuttoIlTesto, vbInformation, _
  "Numero nodi-testo: " & NodiXml.Length
End Sub