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
| Option Explicit
Dim objUser, strExcelPath, objExcel, objSheet, k, objGroup
Const xlExcel7 = 39
On Error Resume Next
Set objExcel = CreateObject("Excel.Application")
If (Err.Number <> 0) Then
On Error GoTo 0
Wscript.Echo "Excel application not found."
Wscript.Quit
End If
On Error GoTo 0
objExcel.Visible = True
objExcel.Workbooks.Add
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
objSheet.Name = "Feuil1"
objSheet.PageSetup.Orientation=2
objSheet.PageSetup.leftmargin=0
objSheet.Cells(1, 1).Value = "Ligne 1 col 1 " & vbCrLf & "suite"
objSheet.Cells(2, 1).Value = "15/06"
objSheet.Cells(2, 1).numberformat="d/m"
objSheet.Cells(3, 1).Value = "ligne 3 col 1"
objSheet.Cells(4, 1).Value = "ligne 4 col 1"
objSheet.Cells(1, 2).Value = "ligne 2 col 2"
objSheet.Cells(2, 2).Value = "ligne 2 col 2"
objSheet.Cells(3, 2).Value = "ligne 3 col 2"
objSheet.Cells(4, 2).Value = "ligne 4 col 2"
objSheet.Cells(5, 1).Value = "ligne 5 col 1 test99"
objSheet.Cells(1, 3).Value = "message multiligne"
objExcel.DisplayAlerts = False
objSheet.Protect "12345", True, True, True, False, False, False, False, False, False, False, False, False, False, False, False
' ou plus simple : objSheet.Protect "12345", True, True, True
' car False est la valeur par défaut pour le reste des paramètres
' à moins qu'on veuille laisser possibles quelques modifications
objSheet.SaveAs "C:\Monfichier.xls", , , , True
objExcel.Quit |
Partager