i cant print selected rows in datagrid so now i have to export the selected rows in excel file so in that way i can print the selected rows..thanx

5 Years
Discussion Span
Last Post by EXTRA_RICE

I haven't used a DataGrid in 12 years and I didn't load Access on this computer, but I did some research for you.

I find no way to pring directly from the DataGrid.

However if you can get the data into something that can be printed, like Excel, then printing is much easier.

My last post will print form excel.
The question the follows: How do you get DataGrid to Excel?
This thread seems to handle that task.
The following is vb6 code that will print the range A1 to D5, tested and works.

Private Sub Print_cmd_Click()
Dim xl As New Excel.Application
Dim wbkdes As Workbook
Dim wsToPrint As Worksheet
    Set wbkdes = xl.Workbooks.Open("C:\YourPath\YourWorkBook.xls")
    Set wsToPrint = wbkdes.ActiveSheet
    With wsToPrint
    End With
    wbkdes.Close True
    Set xl = Nothing
    Set wbkdes = Nothing
    Set wsToPrint = Nothing
    MsgBox "Data Sent to Printer"
End Sub

You may have to format column width in YourWorkBook

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.