Access.2007.VBA.Bibl..

(John Hannent) #1

Enter hours in regular Monday row:


Set rngPC = _
appExcel.ActiveCell.Offset(columnoffset:=3)
Set rngRH = _
appExcel.ActiveCell.Offset(columnoffset:=4)
Set rngOT = _
appExcel.ActiveCell.Offset(columnoffset:=5)
rngCC.Value = ![ClientCode]
rngPC.Value = ![ProjectCode]
rngRH.Value = ![MondayHours]
rngOT.Value = ![MondayOTHours]
End If
End If

[Similar code for processing Tuesday through Sunday hours omitted.]


.MoveNext
Next n

Save and close filled-in worksheet.


Create workbook save name from employee name and week ending date:


strSaveName = strDocsPath & strEmployeeName _
& “ time sheet for week ending “ _
& Format(dteWeekEnding, “d-mmm-yyyy”)
Debug.Print “Time sheet save name: “ _
& strSaveName

On Error Resume Next

If there already is a saved worksheet with this name, delete it:


Kill strSaveName

On Error GoTo ErrorHandler

wkb.SaveAs FileName:=strSaveName, _
FileFormat:=xlWorkbookDefault
wkb.Close

End With
rstAll.MoveNext
Loop

rstAll.Close
rstOne.Close

appExcel.Visible = False

Working with Excel Worksheets 7

Free download pdf