Merci pour ton aide Jean-paul
mais ca ne marche pas je ne c'est pas pourquoi mais ça ne marche pas
j'ai tjr le même message "Voulez-vous enregistrer les modifications apportées à 'classeur1'
même avec Application.DisplayAlerts = False
et la commande : Sheet.Columns(1 + 3).Width = 10
me donne une erreur 1004
"impossible de definnir la propriété width de la classe range"
voici mon code
en bref j'essaie je passe ma grid dans excel et j'imprime
Private Sub Command2_Click()
Dim i, j As Integer
Dim appExcel As Excel.Application 'Application Excel
Dim wbExcel As Excel.Workbook 'Classeur Excel
Dim wsExcel As Excel.Worksheet 'Feuille Excel
'Ouverture de l'application
Set appExcel = CreateObject("Excel.Application")
'Ajout d'un classeur car à l'ouverture d'Excel il n'y a aucun classeur d'ouvert
appExcel.Workbooks.Add 'Ceci n'est nécessaire que si vous n'ouvrez pas un fichier existant
'Récupération du classeur par défaut
Set wbExcel = appExcel.ActiveWorkbook
'Récupération de la feuille par défaut
Set wsExcel = wbExcel.ActiveSheet
Set Sheet = appExcel.ActiveWorkbook.ActiveSheet
Application.DisplayAlerts = True
For i = 0 To Text1.Text - 1
For j = 0 To Text1.Text - 1
Sheet.Cells(i + 3, j + 3).Value = Grid.TextMatrix(i, j)
'mise en forme de la page
Sheet.Cells(i + 3, j + 3).HorizontalAlignment = xlCenter
Sheet.Cells(i + 3, j + 3).Borders(xlEdgeTop).LineStyle = xlContinuous
Sheet.Cells(i + 3, j + 3).Borders(xlEdgeTop).Weight = xlThin
Sheet.Cells(i + 3, j + 3).Borders(xlEdgeTop).ColorIndex = xlAutomatic
Sheet.Cells(i + 3, j + 3).Borders(xlEdgeBottom).LineStyle = xlContinuous
Sheet.Cells(i + 3, j + 3).Borders(xlEdgeBottom).Weight = xlThin
Sheet.Cells(i + 3, j + 3).Borders(xlEdgeBottom).ColorIndex = xlAutomatic
Sheet.Cells(i + 3, j + 3).Borders(xlEdgeLeft).LineStyle = xlContinuous
Sheet.Cells(i + 3, j + 3).Borders(xlEdgeLeft).Weight = xlThin
Sheet.Cells(i + 3, j + 3).Borders(xlEdgeLeft).ColorIndex = xlAutomatic
Sheet.Cells(i + 3, j + 3).Borders(xlEdgeRight).LineStyle = xlContinuous
Sheet.Cells(i + 3, j + 3).Borders(xlEdgeRight).Weight = xlThin
Sheet.Cells(i + 3, j + 3).Borders(xlEdgeRight).ColorIndex = xlAutomatic
'Sheet.Column(1 + 3).Width = 10
Next j
Next i
appExcel.ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Private Sub Command1_Click()
'Printer.PaintPicture MSFlexGrid1.Picture, 10, 12
'Printer.EndDoc
'end sub
'Sheet.PrintOut
wbExcel.Close 'Fermeture du classeur Excel
appExcel.Quit 'Fermeture de l'application Excel
'Désallocation mémoire
Set wsExcel = Nothing
Set wbExcel = Nothing
Set appExcel = Nothing
End Sub