Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Private Sub Comando0_Click()
Dim fSuccess As Boolean
Dim oDoc As MSXML2.DOMDocument
Dim oRoot As MSXML2.IXMLDOMNode ' Level 0 egh_eval
Dim oChild As MSXML2.IXMLDOMNode ' Level 1 eval_set
Dim oChildren As MSXML2.IXMLDOMNode ' Level 2 eval_id, eval_d, eval_e, eval_cred
Dim oChildrenChildren As MSXML2.IXMLDOMNode
Dim domList As MSXML2.IXMLDOMNodeList
Set oDoc = New MSXML2.DOMDocument
oDoc.async = False
oDoc.validateOnParse = False
fSuccess = oDoc.Load("C:\Users\Pierangelo\Downloads\file.xml")
' MsgBox ("You must enter incident Type when textbox 'Type' is empty and the 'AddIncident' button is pressed.")
Set oRoot = oDoc.documentElement
Set oChild = oRoot.childNodes(0)
Set oChildren = oChild.childNodes(0)
' MsgBox oRoot.childNodes.length
' MsgBox oChildren.nodeName & " : " & oChildren.nodeTypedValue
For i = 0 To oRoot.childNodes.length - 1
' MsgBox oRoot.childNodes(i).nodeTypedValue
Next
' loop oggetti FatturaElettronicaHeader
Set oChild = oRoot.childNodes(0)
' dati trasmittente
' MsgBox oChild.childNodes(0).childNodes(0).childNodes(0).nodeName & " : " & oChild.childNodes(0).childNodes(0).childNodes(0).nodeTypedValue ' id paese
' MsgBox oChild.childNodes(0).childNodes(0).childNodes(1).nodeName & " : " & oChild.childNodes(0).childNodes(0).childNodes(1).nodeTypedValue ' id codice fiscale
' MsgBox oChild.childNodes(0).childNodes(1).nodeName & " : " & oChild.childNodes(0).childNodes(1).nodeTypedValue ' progressivo invio
' MsgBox oChild.childNodes(0).childNodes(2).nodeName & " : " & oChild.childNodes(0).childNodes(2).nodeTypedValue ' formato trasmissione
' MsgBox oChild.childNodes(0).childNodes(3).nodeName & " : " & oChild.childNodes(0).childNodes(3).nodeTypedValue ' codice destinatario
' MsgBox oChild.childNodes(0).childNodes(4).nodeName & " : " & oChild.childNodes(0).childNodes(4).nodeTypedValue ' pec
' CedentePrestatore
' MsgBox oChild.childNodes(1).childNodes(0).childNodes(0).childNodes(0).nodeName & " : " & oChild.childNodes(1).childNodes(0).childNodes(0).childNodes(0).nodeTypedValue ' id paese
' MsgBox oChild.childNodes(1).childNodes(0).childNodes(0).childNodes(1).nodeName & " : " & oChild.childNodes(1).childNodes(0).childNodes(0).childNodes(1).nodeTypedValue ' id codicefiscale
' MsgBox oChild.childNodes(1).childNodes(0).childNodes(1).childNodes(0).nodeName & " : " & oChild.childNodes(1).childNodes(0).childNodes(1).childNodes(0).nodeTypedValue ' anagrafica
' MsgBox oChild.childNodes(1).childNodes(0).childNodes(2).nodeName & " : " & oChild.childNodes(1).childNodes(0).childNodes(2).nodeTypedValue ' regime fiscale
' sede cedente prestatore
' MsgBox oChild.childNodes(1).childNodes(1).childNodes(0).nodeName & " : " & oChild.childNodes(1).childNodes(1).childNodes(0).nodeTypedValue ' inidirzzo
' MsgBox oChild.childNodes(1).childNodes(1).childNodes(1).nodeName & " : " & oChild.childNodes(1).childNodes(1).childNodes(1).nodeTypedValue ' cap
' MsgBox oChild.childNodes(1).childNodes(1).childNodes(2).nodeName & " : " & oChild.childNodes(1).childNodes(1).childNodes(2).nodeTypedValue ' comune
' MsgBox oChild.childNodes(1).childNodes(1).childNodes(3).nodeName & " : " & oChild.childNodes(1).childNodes(1).childNodes(3).nodeTypedValue ' provincia
' MsgBox oChild.childNodes(1).childNodes(1).childNodes(4).nodeName & " : " & oChild.childNodes(1).childNodes(1).childNodes(4).nodeTypedValue ' nazione
' CessionarioCommittente
' MsgBox oChild.childNodes(2).childNodes(0).childNodes(0).nodeName & " : " & oChild.childNodes(2).childNodes(0).childNodes(0).nodeTypedValue ' codice fiscale
' MsgBox oChild.childNodes(2).childNodes(0).childNodes(1).childNodes(0).nodeName & " : " & oChild.childNodes(2).childNodes(0).childNodes(1).childNodes(0).nodeTypedValue ' denominazione
' CessionarioCommittente SEDE
' MsgBox oChild.childNodes(2).childNodes(1).childNodes(0).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(0).nodeTypedValue ' inidirizzo
' MsgBox oChild.childNodes(2).childNodes(1).childNodes(1).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(1).nodeTypedValue ' cap
' MsgBox oChild.childNodes(2).childNodes(1).childNodes(2).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(2).nodeTypedValue ' comune
' MsgBox oChild.childNodes(2).childNodes(1).childNodes(3).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(3).nodeTypedValue ' provincia
' MsgBox oChild.childNodes(2).childNodes(1).childNodes(4).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(4).nodeTypedValue ' nazione
' --------------------------------------------------------------------
' Fattura Elettronica Body
Set oChild = oRoot.childNodes(1)
'dati generali
' MsgBox oChild.childNodes(0).childNodes(0).childNodes(0).nodeName & " : " & oChild.childNodes(0).childNodes(0).childNodes(0).nodeTypedValue ' tipo documento
' MsgBox oChild.childNodes(0).childNodes(0).childNodes(1).nodeName & " : " & oChild.childNodes(0).childNodes(0).childNodes(1).nodeTypedValue ' divisa
' MsgBox oChild.childNodes(0).childNodes(0).childNodes(2).nodeName & " : " & oChild.childNodes(0).childNodes(0).childNodes(2).nodeTypedValue ' data
' MsgBox oChild.childNodes(0).childNodes(0).childNodes(3).nodeName & " : " & oChild.childNodes(0).childNodes(0).childNodes(3).nodeTypedValue ' numero
' MsgBox oChild.childNodes(0).childNodes(0).childNodes(4).nodeName & " : " & oChild.childNodes(0).childNodes(0).childNodes(4).nodeTypedValue ' causale
' loop dati ddt
For i = 0 To oChild.childNodes(0).childNodes.length - 1
If oChild.childNodes(0).childNodes(i).nodeName = "DatiDDT" Then
' MsgBox oChild.childNodes(0).childNodes(i).childNodes(0).nodeName & " : " & oChild.childNodes(0).childNodes(i).childNodes(0).nodeTypedValue ' numero ddt
' MsgBox oChild.childNodes(0).childNodes(i).childNodes(1).nodeName & " : " & oChild.childNodes(0).childNodes(i).childNodes(1).nodeTypedValue ' data ddt
End If
Next
' MsgBox oChild.childNodes(1).childNodes.length
' loop dati beni servizi
For i = 0 To oChild.childNodes(1).childNodes.length - 1
' For i = 0 To 1
If oChild.childNodes(1).childNodes(i).nodeName = "DettaglioLinee" Then
' MsgBox oChild.childNodes(1).childNodes(i).childNodes(0).nodeName & " : " & oChild.childNodes(1).childNodes(i).childNodes(0).nodeTypedValue ' numero linea
' MsgBox oChild.childNodes(1).childNodes(i).childNodes(1).nodeName & " : " & oChild.childNodes(1).childNodes(i).childNodes(1).nodeTypedValue ' Descrizione
' MsgBox oChild.childNodes(1).childNodes(i).childNodes(2).nodeName & " : " & oChild.childNodes(1).childNodes(i).childNodes(2).nodeTypedValue ' quantità
' MsgBox oChild.childNodes(1).childNodes(i).childNodes(3).nodeName & " : " & oChild.childNodes(1).childNodes(i).childNodes(3).nodeTypedValue ' prezzo unitario
' MsgBox oChild.childNodes(1).childNodes(i).childNodes(4).nodeName & " : " & oChild.childNodes(1).childNodes(i).childNodes(4).nodeTypedValue ' prezzo totale
' MsgBox oChild.childNodes(1).childNodes(i).childNodes(5).nodeName & " : " & oChild.childNodes(1).childNodes(i).childNodes(5).nodeTypedValue ' aliquota iva
' MsgBox oChild.childNodes(1).childNodes(i).childNodes(6).nodeName & " : " & oChild.childNodes(1).childNodes(i).childNodes(6).nodeTypedValue ' natura
End If
' dati riepilogo
If oChild.childNodes(1).childNodes(i).nodeName = "DatiRiepilogo" Then
' MsgBox oChild.childNodes(1).childNodes(i).childNodes(0).nodeName & " : " & oChild.childNodes(1).childNodes(i).childNodes(0).nodeTypedValue ' Aliquota Iva
' MsgBox oChild.childNodes(1).childNodes(i).childNodes(1).nodeName & " : " & oChild.childNodes(1).childNodes(i).childNodes(1).nodeTypedValue ' Natura
' MsgBox oChild.childNodes(1).childNodes(i).childNodes(2).nodeName & " : " & oChild.childNodes(1).childNodes(i).childNodes(2).nodeTypedValue ' ImponibileImporto
' MsgBox oChild.childNodes(1).childNodes(i).childNodes(3).nodeName & " : " & oChild.childNodes(1).childNodes(i).childNodes(3).nodeTypedValue ' Imposta
' MsgBox oChild.childNodes(1).childNodes(i).childNodes(4).nodeName & " : " & oChild.childNodes(1).childNodes(i).childNodes(4).nodeTypedValue ' Esigibilità Iva
End If
Next
' dati pagamento
' MsgBox oChild.childNodes(2).nodeName
' MsgBox oChild.childNodes(2).childNodes(0).nodeName & " : " & oChild.childNodes(2).childNodes(0).nodeTypedValue ' condizioni pagamento
' MsgBox oChild.childNodes(2).childNodes(1).childNodes(0).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(0).nodeTypedValue ' modalità pagamento
' MsgBox oChild.childNodes(2).childNodes(1).childNodes(1).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(1).nodeTypedValue ' data scadenza pagamento
' MsgBox oChild.childNodes(2).childNodes(1).childNodes(2).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(2).nodeTypedValue ' importo pagamento
' MsgBox oChild.childNodes(2).childNodes(1).childNodes(3).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(3).nodeTypedValue ' istituo finanziario
' MsgBox oChild.childNodes(2).childNodes(1).childNodes(4).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(4).nodeTypedValue ' abi
' MsgBox oChild.childNodes(2).childNodes(1).childNodes(5).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(5).nodeTypedValue '
' ---------------------------------------------------------------------------
' ---------------------------------------------------------------------------
' ---------- pdf ------------------------------------------------------------
' ---------------------------------------------------------------------------
' ---------------------------------------------------------------------------
Dim Word_Application As Word.Application
Dim Word_Document As Word.Document
Dim Word_Document_due As Word.Document
Set Word_Application = CreateObject("Word.Application")
Dim oTable As Table
Dim oTable_due As Table
Dim oCel As Cell
Dim oRow As Row
Dim conta As Integer
Dim oCounter As Integer
Dim posizione As Integer
Dim posizione_array(1000) ' dettaglio linee
' Dim posizione_riepilogo(100) ' dati riepilogo
Dim posizione_riepilogo As Integer
Dim contatore_dettaglio_linee As Integer
contatore_dettaglio_linee = 0
With Word_Application
.Visible = False
.ScreenUpdating = False
Set Word_Document = .Documents.Add
End With
' loop oggetti FatturaElettronicaHeader
Set oChild = oRoot.childNodes(0)
' dati trasmittente
With Word_Application.Selection
.Font.Name = "Trebuchet MS"
.Font.Size = 11
.ParagraphFormat.Alignment = wdAlignParagraphLeft
.TypeText "Dati Trasmittente:"
.TypeParagraph
.Font.Size = 9
.TypeText " Id Paese: " & oChild.childNodes(0).childNodes(0).childNodes(0).nodeTypedValue ' id paese
.TypeParagraph
.TypeText " Cod.Fisc: " & oChild.childNodes(0).childNodes(0).childNodes(1).nodeTypedValue ' id codice fiscale
.TypeParagraph
.TypeText " Progressivo Invio: " & oChild.childNodes(0).childNodes(1).nodeTypedValue ' progressivo invio
.TypeParagraph
.TypeText " Dati Trasmissione: " & oChild.childNodes(0).childNodes(2).nodeTypedValue ' formato trasmissione
.TypeParagraph
.TypeText " Codice Destinatario: " & oChild.childNodes(0).childNodes(3).nodeTypedValue ' codice destinatario
.TypeParagraph
.TypeText " Pec:" & oChild.childNodes(0).childNodes(4).nodeTypedValue ' pec
.TypeParagraph
End With
' CedentePrestatore e Sede Prestatore
With Word_Application.Selection
.ParagraphFormat.Alignment = wdAlignParagraphRight
.Font.Name = "Trebuchet MS"
.Font.Size = 11
.TypeText "Cedente Prestatore:"
.TypeParagraph
.Font.Size = 9
.TypeText oChild.childNodes(1).childNodes(0).childNodes(0).childNodes(0).nodeName & " : " & oChild.childNodes(1).childNodes(0).childNodes(0).childNodes(0).nodeTypedValue ' id paese
.TypeParagraph
.TypeText oChild.childNodes(1).childNodes(0).childNodes(0).childNodes(1).nodeName & " : " & oChild.childNodes(1).childNodes(0).childNodes(0).childNodes(1).nodeTypedValue ' id codicefiscale
.TypeParagraph
.TypeText oChild.childNodes(1).childNodes(0).childNodes(1).childNodes(0).nodeName & " : " & oChild.childNodes(1).childNodes(0).childNodes(1).childNodes(0).nodeTypedValue ' anagrafica
.TypeParagraph
.TypeText oChild.childNodes(1).childNodes(0).childNodes(2).nodeName & " : " & oChild.childNodes(1).childNodes(0).childNodes(2).nodeTypedValue ' regime fiscale
.TypeParagraph
.TypeParagraph
.Font.Size = 11
.TypeText "Sede Cedente Prestatore:"
.TypeParagraph
.Font.Size = 9
.TypeText oChild.childNodes(1).childNodes(1).childNodes(0).nodeName & " : " & oChild.childNodes(1).childNodes(1).childNodes(0).nodeTypedValue ' inidirzzo
.TypeParagraph
.TypeText oChild.childNodes(1).childNodes(1).childNodes(1).nodeName & " : " & oChild.childNodes(1).childNodes(1).childNodes(1).nodeTypedValue ' cap
.TypeParagraph
.TypeText oChild.childNodes(1).childNodes(1).childNodes(2).nodeName & " : " & oChild.childNodes(1).childNodes(1).childNodes(2).nodeTypedValue ' comune
.TypeParagraph
.TypeText oChild.childNodes(1).childNodes(1).childNodes(3).nodeName & " : " & oChild.childNodes(1).childNodes(1).childNodes(3).nodeTypedValue ' provincia
.TypeParagraph
.TypeText oChild.childNodes(1).childNodes(1).childNodes(4).nodeName & " : " & oChild.childNodes(1).childNodes(1).childNodes(4).nodeType ' paese
.TypeParagraph
End With
' CessionarioCommittente
With Word_Application.Selection
.ParagraphFormat.Alignment = wdAlignParagraphLeft
.Font.Name = "Trebuchet MS"
.Font.Size = 11
.TypeText "Cessionario Committente:"
.TypeParagraph
.Font.Size = 9
.TypeText oChild.childNodes(2).childNodes(0).childNodes(0).nodeName & " : " & oChild.childNodes(2).childNodes(0).childNodes(0).nodeTypedValue ' codice fiscale
.TypeParagraph
.TypeText oChild.childNodes(2).childNodes(0).childNodes(1).childNodes(0).nodeName & " : " & oChild.childNodes(2).childNodes(0).childNodes(1).childNodes(0).nodeTypedValue ' denominazione
.TypeParagraph
.Font.Size = 11
.TypeText "Sede Cessionario Committente:"
.TypeParagraph
.Font.Size = 9
.TypeText oChild.childNodes(2).childNodes(1).childNodes(0).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(0).nodeTypedValue ' inidirizzo
.TypeParagraph
.TypeText oChild.childNodes(2).childNodes(1).childNodes(1).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(1).nodeTypedValue ' cap
.TypeParagraph
.TypeText oChild.childNodes(2).childNodes(1).childNodes(2).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(2).nodeTypedValue ' comune
.TypeParagraph
.TypeText oChild.childNodes(2).childNodes(1).childNodes(3).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(3).nodeTypedValue ' provincia
.TypeParagraph
.TypeText oChild.childNodes(2).childNodes(1).childNodes(4).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(4).nodeTypedValue ' nazione
.TypeParagraph
End With
' --------------------------------------------------------------------
' Fattura Elettronica Body
Set oChild = oRoot.childNodes(1)
'dati generali
With Word_Application.Selection
.Font.Name = "Trebuchet MS"
.Font.Size = 13
.TypeText "Dati Generali Fattura:"
.TypeParagraph
.Font.Size = 11
.TypeText oChild.childNodes(0).childNodes(0).childNodes(0).nodeName & " : " & oChild.childNodes(0).childNodes(0).childNodes(0).nodeTypedValue ' tipo documento
.TypeParagraph
.TypeText oChild.childNodes(0).childNodes(0).childNodes(1).nodeName & " : " & oChild.childNodes(0).childNodes(0).childNodes(1).nodeTypedValue ' divisa
.TypeParagraph
.TypeText oChild.childNodes(0).childNodes(0).childNodes(2).nodeName & " : " & oChild.childNodes(0).childNodes(0).childNodes(2).nodeTypedValue ' data
.TypeParagraph
.TypeText oChild.childNodes(0).childNodes(0).childNodes(3).nodeName & " : " & oChild.childNodes(0).childNodes(0).childNodes(3).nodeTypedValue ' numero
.TypeParagraph
.TypeText oChild.childNodes(0).childNodes(0).childNodes(4).nodeName & " : " & oChild.childNodes(0).childNodes(0).childNodes(4).nodeTypedValue ' causale
.TypeParagraph
End With
' loop dati ddt
' c'è il contatore per definire le righe della tabella in word
oCounter = 0
For i = 0 To oChild.childNodes(0).childNodes.length - 1
If oChild.childNodes(0).childNodes(i).nodeName = "DatiDDT" Then
oCounter = oCounter + 1
End If
Next
' loop dati beni servizi
For i = 0 To oChild.childNodes(1).childNodes.length - 1
' For i = 0 To 1
If oChild.childNodes(1).childNodes(i).nodeName = "DettaglioLinee" Then
contatore_dettaglio_linee = contatore_dettaglio_linee + 1
posizione_array(i) = i
End If
' dati riepilogo
If oChild.childNodes(1).childNodes(i).nodeName = "DatiRiepilogo" Then
posizione_riepilogo = i
End If
Next
' MsgBox posizione_array(1)
With Word_Application.Selection
.Font.Name = "Trebuchet MS"
.Font.Size = 10
End With
With Word_Application.Selection
.TypeParagraph
.Paragraphs.Alignment = wdAlignParagraphRight
.TypeParagraph
.Font.Size = 14
.TypeParagraph
Set oTable = Word_Document.Tables.Add(Word_Document.Bookmarks("\Prevsel1").Range, oCounter, 2)
.TypeParagraph
' Set oTable_due = Word_Document.Tables.Add(Word_Document.Bookmarks("\Prevsel2").Range, 10, 6)
Set oTable_due = Word_Document.Tables.Add(Word_Document.Bookmarks("\Prevsel2").Range, contatore_dettaglio_linee + 1, 6)
.TypeParagraph
.Font.Name = "Trebuchet MS"
.Font.Size = 14
.TypeText "Riepilogo:"
.TypeParagraph
.Font.Size = 11
.TypeText oChild.childNodes(1).childNodes(posizione_riepilogo).childNodes(0).nodeName & " : " & oChild.childNodes(1).childNodes(posizione_riepilogo).childNodes(0).nodeTypedValue ' Aliquota Iva
.TypeParagraph
.TypeText oChild.childNodes(1).childNodes(posizione_riepilogo).childNodes(1).nodeName & " : " & oChild.childNodes(1).childNodes(posizione_riepilogo).childNodes(1).nodeTypedValue ' Natura
.TypeParagraph
.TypeText oChild.childNodes(1).childNodes(posizione_riepilogo).childNodes(2).nodeName & " : " & oChild.childNodes(1).childNodes(posizione_riepilogo).childNodes(2).nodeTypedValue ' ImponibileImporto
.TypeParagraph
.TypeText oChild.childNodes(1).childNodes(posizione_riepilogo).childNodes(3).nodeName & " : " & oChild.childNodes(1).childNodes(posizione_riepilogo).childNodes(3).nodeTypedValue ' Imposta
.TypeParagraph
.TypeText oChild.childNodes(1).childNodes(posizione_riepilogo).childNodes(4).nodeName & " : " & oChild.childNodes(1).childNodes(posizione_riepilogo).childNodes(4).nodeTypedValue ' Esigibilità Iva
.TypeParagraph
.Font.Size = 14
.TypeParagraph
.Paragraphs.Alignment = wdAlignParagraphLeft
.TypeText "Dati Pagamento"
.TypeParagraph
.Font.Size = 14
.TypeParagraph
'dati pagamento
.TypeText oChild.childNodes(2).childNodes(0).nodeName & " : " & oChild.childNodes(2).childNodes(0).nodeTypedValue ' condizioni pagamento
.TypeParagraph
.TypeText oChild.childNodes(2).childNodes(1).childNodes(0).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(0).nodeTypedValue ' modalità pagamento
.TypeParagraph
.TypeText oChild.childNodes(2).childNodes(1).childNodes(1).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(1).nodeTypedValue ' data scadenza pagamento
.TypeParagraph
.TypeText oChild.childNodes(2).childNodes(1).childNodes(2).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(2).nodeTypedValue ' importo pagamento
.TypeParagraph
.TypeText oChild.childNodes(2).childNodes(1).childNodes(3).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(3).nodeTypedValue ' istituo finanziario
.TypeParagraph
.TypeText oChild.childNodes(2).childNodes(1).childNodes(4).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(4).nodeTypedValue ' abi
.TypeParagraph
.TypeText oChild.childNodes(2).childNodes(1).childNodes(5).nodeName & " : " & oChild.childNodes(2).childNodes(1).childNodes(5).nodeTypedValue '
End With
With Word_Application.Selection
.Paragraphs.Alignment = wdAlignParagraphLeft
.TypeParagraph
.TypeParagraph
End With
'Dim oTable As Table
'Dim oTable_due As Table
'Dim oCel As Cell
'Dim oRow As Row
'Dim conta As Integer
' ddt
conta = 1
' Set oTable = Word_Document.Tables.Add(Word_Document.Bookmarks("\PrevSel1").Range, oCounter, 2)
oTable.Range.ParagraphFormat.SpaceAfter = 6
oTable.Range.Rows(1).Range.Cells(1).Range.InsertAfter "Numero DDT"
oTable.Range.Rows(1).Range.Cells(2).Range.InsertAfter "Data DDT"
For c = 2 To oCounter
oTable.Range.Rows(c).Cells(1).Range.InsertAfter oChild.childNodes(0).childNodes(conta).childNodes(0).nodeTypedValue ' numero ddt
oTable.Range.Rows(c).Cells(2).Range.InsertAfter oChild.childNodes(0).childNodes(conta).childNodes(1).nodeTypedValue ' data ddt
conta = conta + 1
Next c
oTable.Rows(1).Range.Font.Bold = True
oTable.Rows(1).Range.Font.Italic = True
oTable.Range.Paragraphs.Alignment = wdAlignParagraphLeft
oTable.Range.Font.Size = 10
'' dati fattura
conta = 1
' Set oTable_due = Word_Document.Tables.Add(Word_Document.Bookmarks("\Prevsel2").Range, contatore_dettaglio_linee + 1, 6)
oTable_due.Range.ParagraphFormat.SpaceAfter = 6
oTable_due.Range.Rows(1).Range.Cells(1).Range.InsertAfter "N."
oTable_due.Range.Rows(1).Range.Cells(2).Range.InsertAfter "Descrizione"
oTable_due.Range.Rows(1).Range.Cells(3).Range.InsertAfter "Qt"
oTable_due.Range.Rows(1).Range.Cells(4).Range.InsertAfter "Unitario"
oTable_due.Range.Rows(1).Range.Cells(5).Range.InsertAfter "Totale"
oTable_due.Range.Rows(1).Range.Cells(6).Range.InsertAfter "Iva"
For c = 2 To contatore_dettaglio_linee
' For c = 2 To 5
oTable_due.Range.Rows(c).Cells(1).Range.InsertAfter oChild.childNodes(1).childNodes(posizione_array(conta)).childNodes(0).nodeTypedValue ' numero linea
oTable_due.Range.Rows(c).Cells(2).Range.InsertAfter oChild.childNodes(1).childNodes(posizione_array(conta)).childNodes(1).nodeTypedValue ' Descrizione
oTable_due.Range.Rows(c).Cells(3).Range.InsertAfter oChild.childNodes(1).childNodes(posizione_array(conta)).childNodes(2).nodeTypedValue ' quantità
oTable_due.Range.Rows(c).Cells(4).Range.InsertAfter oChild.childNodes(1).childNodes(posizione_array(conta)).childNodes(3).nodeTypedValue ' prezzo unitario
oTable_due.Range.Rows(c).Cells(5).Range.InsertAfter oChild.childNodes(1).childNodes(posizione_array(conta)).childNodes(4).nodeTypedValue ' prezzo totale
oTable_due.Range.Rows(c).Cells(6).Range.InsertAfter oChild.childNodes(1).childNodes(posizione_array(conta)).childNodes(5).nodeTypedValue ' Iva
conta = conta + 1
Next c
oTable_due.Rows(1).Range.Font.Bold = True
oTable_due.Rows(1).Range.Font.Italic = True
oTable_due.Range.Font.Size = 10
oTable_due.Range.Paragraphs.Alignment = wdAlignParagraphLeft
' oTable_due.AllowAutoFit = True
oTable_due.PreferredWidthType = wdPreferredWidthPoints
oTable_due.PreferredWidth = 500
oTable_due.Range.Rows(1).Range.Cells(1).PreferredWidth = "25"
oTable_due.Range.Rows(1).Range.Cells(2).PreferredWidth = "225"
oTable_due.Range.Rows(1).Range.Cells(3).PreferredWidth = "25"
oTable_due.Range.Rows(1).Range.Cells(4).PreferredWidth = "100"
oTable_due.Range.Rows(1).Range.Cells(5).PreferredWidth = "100"
oTable_due.Range.Rows(1).Range.Cells(6).PreferredWidth = "25"
With Word_Application
.Visible = True
.ScreenUpdating = True
'Save As PDF Document
Word_Document.ExportAsFixedFormat _
OutputFileName:="test.pdf", _
ExportFormat:=wdExportFormatPDF
' ActiveDocument.ExportAsFixedFormat _
OutputFileName:="test.pdf", _
ExportFormat:=wdExportFormatPDF
End With
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.