I have a workbook that calculates times based on certain start time, schedules etc and then using a macro designed sometime ago by a colleague prints all the selected sheets to the default printer - say from rider 1 (lowest number) to rider 10 (highest number) but could be up to 500 sheets, however I would like to amend the macro so it exports the data in one file in a pdf, I've tried just changing the default printer to the microsoft pdf option but that then requires me to name each rider page separately and I'd like them all in one folder to be able to email over - any help would be appreciated I've pasted the code I have below
Thanks
Sub PrintCards()
' PrintCards Macro
' Macro recorded 29/06/2002 by
' Keyboard Shortcut: Ctrl+P
Dim RiderNum As Long, HighestNumber As Long, classnum As Long, RowNumb As Long
Dim strNumber As String, ValidRider As Boolean
'RiderNum = 1
'set timecard section for print area output
ActiveSheet.PageSetup.PrintArea = "$Ak$41:$bg$72"
'set printer page orientation to landscape
Worksheets("Sheet1").PageSetup.Orientation = xlLandscape
'turn error capture on
On Error GoTo catcherror
'get the first Rider Number to print times for
strNumber = InputBox("Enter The First Rider Number for to Print Times for. ", "Timecard Generator,")
RiderNum = Val(strNumber)
'Get the highest Number to be printed.
strNumber = InputBox("Enter The Highest Rider Number to Print Times for. ", "Timecard Generator,")
HighestNumber = Val(strNumber)
FindRiderNum:
'do a loop to keep prog running until HighestNumber
Do While RiderNum <= HighestNumber
'ValidRider = True
With Sheet1.Range("a15:a3000")
Cells.Find(RiderNum, , LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
End With
If ActiveCell.Column = 1 Then 'And ValidRider = True Then
RiderNum = RiderNum + 1
'put a printed logo in line with riders details
ActiveCell.Offset(0, 6).Select
ActiveCell.Value = "Printed."
ActiveCell.Offset(0, -6).Select
'highlight details ready for copy
Range(ActiveCell, ActiveCell.Offset(0, 5)).Select
'copy to clipboard
Selection.Copy
Range("A8").Select
'paste into A8
ActiveSheet.Paste
Application.CutCopyMode = False
'get class number of this rider
Range("f8").Select
classnum = ActiveCell.Value
'work out position of Class Schedule
RowNumb = 9 + (classnum * 7)
'Get the correct class schedule and move it to Range m15
Range(ActiveCell.Offset(RowNumb, 7), ActiveCell.Offset(RowNumb + 5, 26)).Select
'copy to clipboard
Selection.Copy
'select Schedule area
Range("m15").Select
'paste into Schedules area (L15)
ActiveSheet.Paste
Application.CutCopyMode = False
'send timecards to printer
ActiveWindow.allSheets.PrintOut Copies:=1, PrintTofile:=True, Preview:=False, Collate:=True
'clear the pasted entry and class time schedule
Range("a8:f8").Select
Selection.ClearContents
Range("M15:af20").Select
Selection.ClearContents
Range("a15").Select
Else: RiderNum = RiderNum + 1
End If
'to keep timecard prog running
Loop
ActiveWorkbook.Save
ActiveWorkbook.Application.Quit
End
catcherror:
'number not found error
'ValidRider = False
RiderNum = RiderNum + 1
Resume FindRiderNum
End Sub
Bookmarks