Results 1 to 3 of 3

Thread: How do I print the contents of an MSFlexGrid ?

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    9

    Question

    Hello,

    How do I print the contents of an MSFlexGrid to a printer, or even simply to a .txt or .xls file that I can open in
    Notepad, Word or excel then print?

    At the moment I am only able to read the first cell of the MSFlexGrid into either a .txt or .xls file...

    Below is code I am working with at the moment:

    Code:
    Private Sub Command2_Click()
        Dim dTEXTFILE As String
        Dim dTEXT As String
        dTEXTFILE = "C:\FILE.XLS"
        dTEXT = MSFlexGrid1.Text
        Open dTEXTFILE For Output As #1
            Print #1, dTEXT
        Close #1
    End Sub
    Any help would be greatly appreciated, thanks very much,
    Andy............

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Lightbulb

    You can print MsFlexGrid like this:

    Code:
    Private Sub Command1_Click()
        Printer.PaintPicture MSFlexGrid1.Picture, 0, 0
        Printer.EndDoc
    End Sub

  3. #3
    Addicted Member curlywink's Avatar
    Join Date
    Mar 2000
    Location
    Manila, Philippines
    Posts
    141
    Hi there, finally I'm back ...

    Want to try this for example. (save to txt file...)

    'Assumed 'ya know the nos. of cols.
    open "tempfile.txt" for output as #1

    dim iCtr as integer
    With MSFlexGrid1
    For iCtr = 1 To .Rows - 1
    yourvar1 = .TextMatrix(iCtr, 0) ' first col
    yourvar2 = .TextMatrix(iCtr, 1) ' second "
    yourvar3 = .TextMatrix(iCtr, 2) ' third "
    Write #1,yourvar1,yourvar2,yourvar3
    Next
    End With
    close #1

    ' Hope this can help ya

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width