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!

MSFlexGrid & Copy

Status
Not open for further replies.

dodgyone

Technical User
Jan 26, 2001
431
GB
What I would like is to be able to copy the flexgrid that I am using so that I can paste it into an e-mail.

I have the e-mail code etc but using code how would I copy the flexgrid and then use this value to paste into a specific area on the e-mail page?

Thanks...
 
dodgyone - I needed to print a MSFlexGrid, and found that
PrintForm would not work. So I copy the grid to a Picture
Control, then print the picture.

You may be able to tweak the following code to enable you to copy and paste. If you use a Picture control, set the Visible property to False.

Maybe this will get you started....
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