Print listview listitems and columnheader
How to set the A4 paper to print the listview listitems and listview column header as lanscape or potrait?By default it print as potrait. So How to set the paper to print as lanscape if the columnheader reach the A4 limit margin size?
Code:
'Print Column Header
Dim head As ColumnHeader
Dim colColumnIndexes As Collection
Dim Idx As Long
Dim iTab As Long
Set colColumnIndexes = New Collection
iTab = 5
Printer.FontUnderline = True
'Print the column headers and load the collection of
'column indexes that will be used when printing the ListView data.
For Idx = 0 To printtext.List2.ListCount - 1
For Each head In Form5.ListView2.ColumnHeaders
If printtext.List2.List(Idx) = head.Text Then
Printer.Print Tab(iTab); printtext.List2.List(Idx);
iTab = iTab + 30
colColumnIndexes.Add head.SubItemIndex
End If
Next
Next
Printer.Print
Printer.Print vbCrLf
'Print ListItem
Dim item As ListItem
Dim strItem As String
For Each item In Form5.ListView2.ListItems
iTab = 5
For Idx = 1 To colColumnIndexes.Count
Printer.FontUnderline = False
If colColumnIndexes(Idx) = 0 Then 'this is not a subitem, so print the listitem data
strItem = item.Text
Else
strItem = item.ListSubItems(colColumnIndexes(Idx)).Text
End If
Printer.Print Tab(iTab); strItem;
iTab = iTab + 25
Next
Printer.Print
Next
Printer.EndDoc