Sub Création_Exemple()
Application.ScreenUpdating = False
ENTETE_DOC_EXEMPLE
EXEMPLE_TABLEAU
End Sub
Sub ENTETE_DOC_EXEMPLE()
With Selection
.TypeText Text:="RAISON SOCIALE EXPEDITEUR"
.ParagraphFormat.TabStops.Add Position:=CentimetersToPoints(10.25), Alignment:=0, Leader:=0
.TypeText Text:=vbTab & "Ville, le "
.InsertDateTime DateTimeFormat:="dddd d MMMM yyyy", InsertAsField:=True, DateLanguage:=1036, CalendarType:=0, InsertAsFullWidth:=False
.TypeParagraph: .TypeText Text:="ADRESSE 1"
.TypeParagraph: .TypeText Text:="ADRESSE 2"
.TypeParagraph: .TypeText Text:="CP VILLE"
.TypeParagraph: .TypeText Text:="TITRE DU DOCUMENT"
.TypeParagraph: .TypeParagraph: .TypeParagraph
End With
With ActiveDocument.Paragraphs(5)
.Alignment = 1: .Range.Bold = True
.Range.Font.Size = 14: .Range.Borders(1).LineStyle = 7
End With
End Sub
Sub EXEMPLE_TABLEAU()
Dim objTable As Table, i As Long
Set objTable = ActiveDocument.Tables.Add(Range:=Selection.Range, NumRows:=120, NumColumns:=4)
objTable.Borders.InsideLineStyle = 1
objTable.Borders.OutsideLineStyle = 1
Randomize
With objTable
For i = 1 To objTable.Rows.Count
.Cell(i, 1).Range.Text = i
.Cell(i, 2).Range.Text = Chr(Int((90 - 65 + 1) * Rnd + 65)) & "|" & Right(Application.Build, 4) + i
.Cell(i, 3).Range.Text = Chr(Int((57 - 48 + 1) * Rnd + 48)) & "|" & Application.UserName
.Cell(i, 4).Range.Text = Application.Language + i
Next i
End With
End Sub