Set appExcel = Nothing
MsgBox “All time sheet workbooks created in “ _
& strDocsPath
ErrorHandlerExit:
Exit Function
ErrorHandler:
Excel is not running; open Excel with CreateObject:
If Err.Number = 429 Then
Set appExcel = CreateObject(“Excel.Application”)
Resume Next
Else
MsgBox “Error No: “ & Err.Number _
& “; Description: “
Resume ErrorHandlerExit
End If
End Function
This procedure creates a new Excel worksheet from a template for each record. This template is
pre-filled with standard text, colors, and other features; all it needs is to have the timesheet data
filled in from the Access record.
Summary ..........................................................................................................................
With the techniques described in this chapter, you can export data in Access tables to Excel
worksheets in a variety of formats, for compatibility with older Office versions or handheld
devices. You can use the Excel button on the Ribbon to do a quick-and-dirty export to the new
.xlsx format, or create a worksheet in an older format that can be synchronized with a PDA, using
the TransferSpreadsheetmethod. And finally, when you need to output your data to an
Excel worksheet in a specific format, you can use a preformatted worksheet template, or format a
plain worksheet using VBA Automation code to get the exact results you want.
Part II Writing VBA Code to Exchange Data between Office Components