- Код: Выделить всё
Set objExcel = GetObject(, "Excel.Application")
If Err.Number Then
Err.Clear
Set objExcel = CreateObject("Excel.Application")
If Err.Number Then
MsgBox "Не могу загрузить Excel."
Exit Sub
End If
End If
Set objWorkbook = objExcel.Workbooks.add
AppActivate "Реестр отправленных отчетов за "
objWorkbook.ActiveSheet.Range("A1:N1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
.Merge
.Font.Size = 12
.Font.Bold = True
End With
objWorkbook.ActiveSheet.Range("A1") = "Реестр отправленной отчетности"
kol_rows = MSFlexGrid1.Rows - 1
With objWorkbook.ActiveSheet
For i = 0 To MSFlexGrid1.Rows - 1
MSFlexGrid1.row = i
For n = 0 To MSFlexGrid1.Cols - 2
MSFlexGrid1.col = n
.Cells(i + 3, n + 1).NumberFormat = "@"
.Cells(i + 3, n + 1).Font.Size = 10
.Cells(i + 3, n + 1).Value = MSFlexGrid1.Text
.Columns(n + 1).AutoFit
Next
Next
End With
objWorkbook.ActiveSheet.Rows("3:3").Select
With Selection
.Font.Size = 12
.Font.Bold = True
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
'Рамки
Range("A3:N" & MSFlexGrid1.Rows + 2).Select
With Selection
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlInsideVertical).LineStyle = xlContinuous
.Borders(xlInsideHorizontal).LineStyle = xlContinuous
End With
With objWorkbook.ActiveSheet
.Rows("3").Select
.Columns.AutoFit
End With
objWorkbook.ActiveSheet.Cells("1,1").Select
objExcel.Visible = True
Set objExcel = Nothing