Private Sub ExportToExcel(pLink As Integer)
On Error GoTo Err_Routine
Dim appExcel As Excel.Application
Dim wbk As Excel.Workbook
Dim wks As Excel.Worksheet
Dim sTemplate As String
Dim sTempFile As String
Dim sOutput As String
Const cTabTwo As Byte = 1
Const cStartRow As Byte = 6
Const cStartColumn As Byte = 1
sTemplate = CurrentProject.Path & "\Mag moto report- VMMT-204 Template.xls"
sOutput = CurrentProject.Path & "\Monthly Wing Totals for VMMT-204 " & Format(Date, "ddmmmyyyy") & ".xls"
If Dir(sOutput) <> "" Then Kill sOutput
FileCopy sTemplate, sOutput
' Create the Excel Applicaiton, Workbook and Worksheet and Database object
Set appExcel = Excel.Application
Set wbk = appExcel.Workbooks.Open(sOutput)
Set wks = appExcel.Worksheets(cTabTwo)
wks.Cells(5, "D") = Me.txtTotalOnHwy
wks.Cells(6, "D") = Me.txtSportBRCCount
wks.Cells(7, "D") = Me.txtSportSRCCount
wks.Cells(9, "D") = Me.txtCruiserBRCCount
wks.Cells(10, "D") = Me.txtCruiserERCCount
wks.Cells(12, "D") = Me.txtSportNeedsBRCCount + Me.txtCruiserNeedsBRCCount
wks.Cells(13, "D") = Me.txtSportNeedsSRCCount
wks.Cells(14, "D") = Me.txtCruiserNeedsERCCount
wks.Cells(16, "D") = Me.txtRiderCoach
wks.Cells(18, "D") = Me.txtATV
wbk.Save
wbk.Close
If pLink = 1 Then
OpenExcelFile (sOutput)
ElseIf pLink = 2 Then
SendSpreadSheet (sOutput)
ElseIf pLink = 3 Then
DisplayEmailToSend (sOutput)
End If
exit_Here:
' Cleanup all objects (resume next on errors)
On Error Resume Next
Set wks = Nothing
Set wbk = Nothing
Set appExcel = Nothing
Set db = Nothing
DoCmd.Hourglass False
Exit Sub
Err_Routine:
ExportRequest = Err.Description
Resume exit_Here
End Sub