donc voici toute la fonction :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| Dim appli As New Microsoft.Office.Interop.Word.Application
Dim docum As Microsoft.Office.Interop.Word.Document
docum = appli.Documents.Add
Dim indiceDeb, indiceFin As Integer
Dim indiceDeb2, indiceFin2 As Integer
Dim dRange As Microsoft.Office.Interop.Word.Range
dRange = docum.Range
indiceDeb = docum.Content.Text.Length
docum.Content.InsertAfter(NomListe.ToString & vbCrLf & vbCrLf)
indiceFin = docum.Content.Text.Length
appli.Selection.SetRange(indiceDeb, indiceFin - 2)
appli.Selection.Font.Bold = True
appli.Selection.Font.Size = 12
appli.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter
appli.Selection.Font.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineSingle
indiceDeb = docum.Content.Text.Length - 2
'----
Dim i As Integer
Dim nbdos As Integer
For i = 0 To dt.Tables("rechnum").Rows.Count - 1
nbdos = i + 1
docum.Content.InsertAfter(nbdos.ToString + ") " + dt.Tables("rechnum").Rows(i)(1).ToString() + dt.Tables("rechnum").Rows(i)(2).ToString() + " " + dt.Tables("rechnum").Rows(i)(3).ToString() + " " + dt.Tables("rechnum").Rows(i)(4).ToString() & vbCrLf)
Next i
appli.Selection.SetRange(indiceDeb, indiceFin - 2)
appli.Selection.Font.Size = 11
appli.Selection.Font.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineSingle
indiceDeb = docum.Content.Text.Length
indiceFin = docum.Content.Text.Length
'MsgBox(NomListe)
Dim fs As IO.Directory
If Not fs.Exists("c:\Statistique\") Then
fs.CreateDirectory("c:\Statistique\")
End If
docum.SaveAs("c:\Statistique\" + NomListe + ".doc")
docum.Close()
appli.Quit() |
et une partie d'une autre :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| docum.Content.InsertAfter(vbCrLf)
docum.Content.InsertAfter("Répartition des " + (Nbrdos1 - Nbrdos12).ToString + " dossiers " & vbCrLf)
indiceFin = docum.Content.Text.Length
appli.Selection.SetRange(indiceDeb, indiceFin - 2)
appli.Selection.Font.Size = 12
appli.Selection.Font.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineSingle
indiceDeb = docum.Content.Text.Length
docum.Content.InsertAfter(vbCrLf)
docum.Content.InsertAfter("3) 22-Retraits : " + NbrdosRetrait.ToString & vbCrLf)
docum.Content.InsertAfter("4) 23-Suspends : " + NbrdosSuspends.ToString & vbCrLf)
docum.Content.InsertAfter("5) Arrêts en fin d'aide : " + Nbaidefin.ToString & vbCrLf)
docum.Content.InsertAfter("6) Arrêts en fin d'aide suivi d'un refus d'une nouvelle aide : " + Nbarretfinsuivi.ToString & vbCrLf)
indiceFin = docum.Content.Text.Length
appli.Selection.SetRange(indiceDeb, indiceFin - 2)
appli.Selection.Font.Size = 12
indiceDeb = docum.Content.Text.Length |
Cette ligne :
docum.Content.InsertAfter
insère du texte après le dernier caractère,
Si tu veux passer à la ligne il suffit d'insèré la constante vb : vbCrLf
comme ceci :
docum.Content.InsertAfter(vbCrLf)
tu peux aussi faire une sélection :
appli.Selection.SetRange(indiceDeb, indiceFin - 2)
sur laquelle tu appliqueras des styles...
1 2
| appli.Selection.Font.Size = 12
appli.Selection.Font.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineSingle |
Bien à toi
Partager