Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Printing Flex Grid

Posted on 2004-03-31
5
Medium Priority
?
550 Views
Last Modified: 2008-01-09
i wanna to print a taple from the type FGrid  the quistion is how can i print it in the wide of peaper ...."the gool of this to print the all taple elements"...and i wanna to print it alone i mean..that .i wanna to print the just the table...with out the else objects..
omar.
0
Comment
Question by:Omar_layous
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 320 total points
ID: 10729791
Multiple possibilities
1)
Public Sub MSFlexGridPrint(gridQuery As Control)
   ' *** Print MSFlexGrid

   Dim I          As Integer
   Dim J          As Integer
   Dim PTab       As Integer

   For I = 1 To gridQuery.Rows - 1
      PTab = 20 'Set the first tab value
      'This checks to see if a page break is needed

      If Printer.CurrentY + Printer.TextHeight(gridQuery.Text) > Printer.ScaleHeight - 600 Then
         Printer.NewPage
      End If

      gridQuery.Row = I 'Set the active row

      For J = 0 To gridQuery.Cols - 1
         gridQuery.Col = J 'Set the current column
         
         'Send the field to the print line and add the tab.
         'Notice the semicolon at the end of the line.

         Printer.Print Trim$(gridQuery.Text); Tab(PTab);

         PTab = PTab + 20 'Increment the tab value
      Next

      'After each column has printed to the print line

      'a Printer.Print statement without a semicolon will
      'will send the line to the printer and start a new
      'one.
      Printer.Print
 Next

End Sub  

2)
MSFlexigrid1.TextMatrix(1,1) - this gives the content in the first row, first column. Likewise, when you put in a For Loop u can get the content in each cell. Further, for each row of data, you can append to a string and pass it to the printer object.

(Eg):

For Ctr = 1 to MSFlexigrid1.Rows - 1
 strcontent = MSFlexigrid1.TextMatrix(Ctr,1)
 strcontent = strcontent & MSFlexigrid1.TextMatrix(ctr,2)

' where 1 & 2 are the columns. Like wise you can continue to build the string for each row & finally print.

printer.print strcontent

Next

4) Export to an invisible excel and print
try this out!!

Public Sub FlexGrid_To_Excel(TheFlexgrid As MSFlexGrid, _
TheRows As Integer, TheCols As Integer, mode As Integer)
 
Dim objXL As New Excel.Application
Dim wbXL As New Excel.Workbook
Dim wsXL As New Excel.Worksheet
Dim intRow As Integer
Dim intCol As Integer

On Error Resume Next

' open Excel
If mode = 1 Then
  objXL.Visible = True
Else
  objXL.Visible = False
End If
Set wbXL = objXL.Workbooks.Add
Set wsXL = objXL.ActiveSheet

' this is to fill the worksheet
For intRow = 1 To TheRows
  For intCol = 1 To TheCols
      With TheFlexgrid
          wsXL.Cells(intRow, intCol).Value = _
             .TextMatrix(intRow - 1, intCol - 1) & " "
             wsXL.Columns(intCol).AutoFit
      End With
  Next
Next
If mode = 2 Then
  wsXL.PrintOut
End If
End Sub

5)
Here's a quick way to print a MSFlexGrid control's contents:
    Printer.PaintPicture MSFlexGrid_Name.Picture, 0, 0
  Printer.EndDoc

And if you want it to be the full length of the printer page add this before those two statements:
    Dim old_width as Integer
  MSFlexGrid_Name.width=printer.width

and this at the end:
     MSFlexGrid_Name.width=old_width
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 11256754
My recommandation: answered by Dhaest
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question