
07/05/2008, 16:17
|
| | Fecha de Ingreso: agosto-2006
Mensajes: 110
Antigüedad: 18 años, 9 meses Puntos: 0 | |
Re: imprimir datagrid x q la funcion para imprimir es esta:
Public Function imprimir(ByVal DataGrid As DataGrid, _
ByVal rs3 As ADODB.Recordset, _
ByVal Titulo As String) As Boolean
Dim c As Integer
Dim dato As String
Dim Titles As String
Dim Header As String
Dim l As Integer 'number of lines For portrait
Dim LLCount As Integer 'temporary line counter
Dim Rowado As Integer
Dim Rowdatag As Integer
Dim registro As String * MAX_CARACTERES
Dim t As String * MAX_CARACTERES
Screen.MousePointer = vbHourglass
DataGrid1.Row = 0
Header = " PRODUCTOS:"
Printer.Font.Size = 10
Printer.Font.Bold = True
Printer.Font.Name = "Courier"
Printer.Print " SUCURSAL: "; Label3
Printer.Print " "
Printer.Print " FECHA: "; Label4
For c = 1 To DataGrid.Columns.Count
t = DataGrid.Columns(c - 1).Caption
Titles = " " & LTrim(Titles & t) & " "
Next
' Configura la fuente de la impresión para el encabezado
Printer.Font.Size = 8
Printer.Font.Bold = True
Printer.Font.Name = "courier"
l = 82
' imprime el titulo , el encabezado y el número de página
Printer.Print Space(20) & Titulo
Printer.Print Header; Printer.Page
Printer.Print Titles
Printer.Font.Bold = False
DataGrid.Refresh
' recorre los datos del datagrid
For Rowado = 1 To Int((rs3.RecordCount - 1) / 13) + 1
For Rowdatag = 0 To DataGrid.VisibleRows - 2
DataGrid.RowBookmark (Rowdatag)
dato = Space(MAX_CARACTERES)
Dim s As Variant
For c = 1 To DataGrid.Columns.Count
registro = DataGrid.Columns(c - 1).CellText(DataGrid.Bookmark)
dato = " " & LTrim(dato & registro) & " "
Next
LLCount = LLCount + 1
If LLCount <= l Then
Printer.Print dato
Else
' Agrega una nueva hoja
Printer.NewPage
Printer.Print Space(40) & Titulo
Printer.Print Header; Printer.Page
Printer.Print Titles
Printer.Print dato
LLCount = 0
End If
rs3.MoveNext
Next Rowdatag
DataGrid.Scroll 0, DataGrid.VisibleRows
Next Rowado
Printer.Print " "
Printer.EndDoc
Screen.MousePointer = vbNormal
imprimir = True
Exit Function
' error
Error_Function:
MsgBox Err.Description, vbCritical
End Function |