Private Sub cmdPrintSheet_Click()
'01/25/2009 - hack
Dim i As Integer
Dim j As Integer
Dim arrSheetName() As String
WkbExisting.Activate
If chkSaveRunDate.Value = True Then
WkbExisting.Save
End If
For i = 0 To lstSheets.ListCount - 1
If lstSheets.Selected(i) = True Then
'put all selected sheets into a single array
'so our consecutive page numbering will work
ReDim Preserve arrSheetName(j)
arrSheetName(j) = lstSheets.List(i)
WkbExisting.Worksheets(arrSheetName(j)).Select
If lstSheets.List(i) = "Comments" Then
ActiveSheet.PageSetup.LeftFooter = vbNullString
ActiveSheet.PageSetup.RightFooter = vbNullString
If chkCommentsPageNumber.Value = True Then
ActiveSheet.PageSetup.CenterFooter = "Page &P Of &N"
Else
ActiveSheet.PageSetup.CenterFooter = vbNullString
End If
Else
'these are the default footers for all sheets EXCEPT Comments
If chkLeftFooter.Value = False Then
ActiveSheet.PageSetup.LeftFooter = Application.ActiveWorkbook.FullName
Else
ActiveSheet.PageSetup.LeftFooter = vbNullString
End If
ActiveSheet.PageSetup.CenterFooter = "Page &P of &N"
ActiveSheet.PageSetup.RightFooter = "Run Date: " & txtRunDate.Text
End If
j = j + 1
End If
Next
If j = 0 Then Exit Sub
WkbExisting.Worksheets(arrSheetName).PrintOut Copies:=1, Collate:=True
WkbExisting.Worksheets(arrSheetName(0)).Select 'ungroup selected sheets
End Sub