Espacio entre columnas
MRTOOL ya encontré una forma de imprimir un formulario con el datagrid, pero al imprimir el datagrid me imprime solo 4 columnas de 6 que tengo, te dejo el siguiente código para que por favor me ayudes, es urgente:
Public Function imprimir(ByVal DataGrid As DataGrid, _
ByVal Rec3 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 = " - Página n°: "
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 New"
l = 82
' Imprime el titulo, el encabezado y el número de página
Printer. Print Space(10) & 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((Rec3.RecordCount - 1) / 13) + 1
For Rowdatag = 0 To DataGrid.VisibleRows - 1
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
Rec3.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
Necesito que todas las columnas aparezcan al imprimir.
Public Function imprimir(ByVal DataGrid As DataGrid, _
ByVal Rec3 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 = " - Página n°: "
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 New"
l = 82
' Imprime el titulo, el encabezado y el número de página
Printer. Print Space(10) & 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((Rec3.RecordCount - 1) / 13) + 1
For Rowdatag = 0 To DataGrid.VisibleRows - 1
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
Rec3.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
Necesito que todas las columnas aparezcan al imprimir.
1 respuesta
Respuesta de mrtool
1