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
|
Dim appExcel As Excel.Application
Dim wbk As Excel.Workbook, wsh As Excel.Worksheet
Try
appExcel = New Excel.Application
wbk = appExcel.Workbooks.Add
wsh = CType(wbk.Worksheets(1), Excel.Worksheet)
appExcel.Visible = True
'fusionner A1:C3
wsh.Range(wsh.Cells(1, 1), wsh.Cells(3, 3)).Merge()
'change la couleur de fond de "D4:E5" en rouge
wsh.Range(wsh.Cells(4, 4), wsh.Cells(5, 5)).Interior.ColorIndex = 3
'encadre le contour de la zone fusionnée d'un trait continu
wsh.Range(wsh.Cells(1, 1), wsh.Cells(3, 3)).BorderAround(Excel.XlLineStyle.xlContinuous, Excel.XlBorderWeight.xlMedium, Excel.XlColorIndex.xlColorIndexAutomatic)
'trace toutes les bordures des cellules de la deuxième zone en pointillés bleus
With wsh.Range(wsh.Cells(4, 4), wsh.Cells(5, 5))
Dim MonEnum As IEnumerator = .Borders.GetEnumerator
Do While MonEnum.MoveNext
With CType(MonEnum.Current, Excel.Border)
.LineStyle = Excel.XlLineStyle.xlDashDot
.Weight = Excel.XlBorderWeight.xlHairline
.Color = Microsoft.VisualBasic.QBColor(1)
End With
Loop
End With
Catch ex As Exception
Finally
wsh = Nothing
wbk.Close(False)
wbk = Nothing
appExcel.Quit()
appExcel = Nothing
End Try |
Partager