Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing a flexgrid

Status
Not open for further replies.

dragnut

Technical User
Dec 27, 2000
125
US
Im trying to print out the contents of a mshflexgrid. All I gt printed is the top left cell though. What did I do wrong here??? this is in a command button

Printer.FontName = MSHFlexGrid1.FontName
Printer.FontBold = MSHFlexGrid1.FontBold
Printer.FontItalic = MSHFlexGrid1.FontItalic
Printer.FontSize = MSHFlexGrid1.FontSize
Printer.Print MSHFlexGrid1
Printer.EndDoc

I must be missing something here.
Thanks in advance
Dragnut
 
Hi dragnut -

Why did Microsoft make this so hard ?

Try this code for printing a grid....

- add a Picture Control (set Visible property to FALSE)

Pls let me know if this worked for you.

John

Private Sub btnPrintGrid_Click()
'When the form contains a M$FlexGrid, the usual way of printing a form, the PrintForm method,
'will result in no grid data showing on the print-out.
'Sooo... this sub copies the grid image to a Picture control,
'then sends the Picture control to the printer.
'It works surprisingly well and is much easier than exporting
'data to an Excel worksheet for the purpose of printing.
'Note: Make the Picture controls VISIBLE property = False
'This method works in VB 6.
'(I dont know if all the data will print when the grid contains
'more rows than can fit on 1 screen)

Dim sScale As Double
Dim sHeading As String
sHeading = "Frigidaire: Virtual Loads"

Printer.Orientation = vbPRORLandscape
Picture1.Picture = MSFlexGrid1.Picture
sScale = Printer.ScaleHeight * (MSFlexGrid1.Rows / 50)
Printer.CurrentX = 100
Printer.Font = "Arial"
Printer.FontSize = "14"
Printer.FontBold = False
Printer.Print sHeading
' print the date/time
' move down a line
Printer.CurrentX = 0
Printer.CurrentY = Printer.TextHeight(sHeading) * 1
Printer.Print "Date: " & Now
Printer.PaintPicture Picture1.Picture, 0, 500, Printer.ScaleWidth, sScale
Printer.EndDoc

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top