Escolar Documentos
Profissional Documentos
Cultura Documentos
'**************************************
'Windows API/Global Declarations for :Ex
' port Database to Excel Report
'**************************************
Please add a reference to
Microsoft Excel 9.0(or 8.0) object library.
'**************************************
' Name: Export Database to Excel Report
' Description:This is the code that expo
' rt a database on DAO (whatever what file
Option Explicit
objExcelApp.Visible = True
objExcelApp.ActiveWorkbook.Worksheets.Add
Set objSheet = objExcelApp.ActiveWorkbook.ActiveSheet
intCurrentRow = intInitialRow
Set rstTarget = datTarget.Recordset.Clone
For J = 0 To rstTarget.Fields.Count - 1
objSheet.Cells(intCurrentRow + 1, J + 1).Value =
rstTarget.Fields(J).Name
Next J
rstTarget.MoveLast
intNum = rstTarget.RecordCount
rstTarget.MoveFirst
I = intCurrentRow + 2
For J = 0 To rstTarget.Fields.Count - 1
If Not IsNull(rstTarget.Fields(J)) Then
objSheet.Cells(I, J + 1).Value = rstTarget.Fields(J).Value
Next J
I = I + 1
rstTarget.MoveNext
Loop
objSheet.Range(objSheet.Cells(intCurrentRow + 1, 1),
objSheet.Cells(intCurrentRow + 1, rstTarget.Fields.Count)).Select
objExcelApp.Selection.EntireColumn.AutoFit
objExcelApp.Selection.Interior.ColorIndex = 24
objSheet.Range(objSheet.Cells(intCurrentRow + 1, 1),
objSheet.Cells(I - 1, rstTarget.Fields.Count)).Select
With objExcelApp.Selection
.Borders(7).Weight = 4
.Borders(7).ColorIndex = -4105
.Borders(8).Weight = 4
.Borders(8).ColorIndex = -4105
.Borders(9).Weight = 4
.Borders(9).ColorIndex = -4105
.Borders(10).Weight = 4
.Borders(10).ColorIndex = -4105
.Borders(11).Weight = 2
.Borders(11).ColorIndex = -4105