Bonjour tout le monde,
Je voudrai imprimer un tableau,pour cela j'utilise un MsFlexGrid pour afficher ce tableau et j'ai fait un boutant imprimer pour afficher ce tableau sous format Word mais le PROBLEME qui se pose c'est que j'ai beaucoup de colonnes dans ce tableau et alors il ne s'affiche pas correctement , je voudrai savoir est ce qu'on peut modifier la taille de police pour que toutes les colonnes s'affiche correctement.
Voilà le code que j'ai utilisé dans le boutant imprimer :
Private Sub cmdimprimer_Click()
On Error Resume Next
'Early object binding
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oRange As Word.Range
'Uncomment below for late object binding
'Dim oWord As Object
'Dim oDoc As Object
'Dim oRange As Object
Dim row As Integer
Dim col As Integer
Dim I As Integer
Dim n As Integer
Dim sTemp As String
Dim arr() As String
ReDim arr(MSFlexGrid1.Rows - 1, MSFlexGrid1.Cols - 1)
'Créer une instance de word
Set oWord = CreateObject("Word.Application")
'rendre le document word visible
oWord.Visible = True
'Ouivrir un nouveau document
Set oDoc = oWord.Documents.Add
'****************
With oWord.Selection
.TypeParagraph
.Font.Color = wdColorDarkBlue
.TypeText Text:="OFFICE DES CHANGES LE :"
.TypeText Date
.TypeParagraph
.TypeText Text:="DIVISION SYSTEME D'INFORMATION"
.TypeParagraph
.TypeParagraph
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Font.Color = wdColorDarkRed
.TypeText Text:="CONSULTATION DES AUTORISATIONS FINANCIERES SANS NOMS"
.TypeParagraph
.TypeParagraph
.ParagraphFormat.Alignment = wdAlignParagraphLeft
.Font.Color = wdColorBlack
.TypeText Text:="N°D'AUTORISATION :"
.Font.Color = wdColorRed
.TypeText MSFlexGrid1.TextMatrix(1, 0)
.TypeParagraph
.Font.Color = wdColorBlack
'.TypeText Text:="Date d'Autorisation :"
.Font.Color = wdColorRed
'.TypeText MSFlexGrid1.TextMatrix(1, 1)
.TypeParagraph
End With
'**************
For row = 0 To MSFlexGrid1.Rows - 1
n = 0
For col = 0 To MSFlexGrid1.Cols - 1
arr(I, n) = MSFlexGrid1.TextMatrix(row, col)
n = n + 1
Next
I = I + 1
Next
'ENregistrer sur un tableau
For I = LBound(arr, 1) To UBound(arr, 1)
For n = LBound(arr, 2) To UBound(arr, 2)
sTemp = sTemp & arr(I, n)
If n = UBound(arr, 2) Then
sTemp = sTemp & vbCrLf
Else
sTemp = sTemp & vbTab
End If
Next
Next
'Avoir l'emplacelent sur le document
Set oRange = oDoc.Bookmarks("\EndOfDoc").Range
oRange.Text = sTemp
'Convertire le format et le texte
oRange.ConvertToTable vbTab, Format:=wdTableFormatColorful2
Set oRange = Nothing
'***********************
oWord.PrintPreview = True
End Sub
Merci de votre aide.