Results 1 to 5 of 5

Thread: Probably reeeeeealy obvious.....

  1. #1

    Thread Starter
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425

    Question

    I have a nagging suspicion that I'm making things far to difficult for myself, but here goes.

    Short of making a huge loop that would individually print each cell, how do I print the entire contents of a Microsoft Flex Grid? I could just print the form, but that wouldn't look very cool..


    TIA!

  2. #2

  3. #3
    New Member
    Join Date
    Dec 2000
    Location
    Victoria BC Canada
    Posts
    1

    Cool

    If you are doing any serious grid work, get the latest videosoft version, which has a load 'o new properties/methods and is WAY better. Otherwise, isn't there a print method?

  4. #4
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Hello CyberSurf,

    Here is one method of printing your data. This will save to a text file. Otherwise, you can use COPYFROMRECORDSET method and send all your data to Excel.

    Code:
    'OVERALL: Place everything from the grid into a textfile
    Private Sub cmdPut_Click()
      If Dir(App.Path & "\Test.txt") <> "" Then Kill App.Path & "\Test.txt"
      
      'PURPOSE: Initiates the coordinates of Top-Left
      MSHFlexGrid1.Row = 1
      MSHFlexGrid1.Col = 0
      'PURPOSE: Initiates the coordinates of Bottom-Right
      MSHFlexGrid1.RowSel = MSHFlexGrid1.Rows - 1
      MSHFlexGrid1.ColSel = MSHFlexGrid1.Cols - 1
      
      'PURPOSE: Sticks everything in the MSHFlexGrid Grid into a string
      Dim str_Buffer As String
      str_Buffer = MSHFlexGrid1.Clip
      
      'Notice: Get rid of all vbcrlf that is in textbox(not grid) or when
      '         import back in, grid will think it is another record
      
      'PURPOSE: Replace vbCR with vbCrLf so that each row from the grid
      '         gets output the same in text file
      str_Buffer = Replace(str_Buffer, vbCr, vbCrLf)
      
      'PURPOSE: Save the string as a whole
      Open App.Path & "\Test.txt" For Binary As #1
      Put #1, , str_Buffer
      Close #1
    End Sub
    Chemically Formulated As:
    Dr. Nitro

  5. #5
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Here is an example of CopyFromRecordset.

    Excel97 = Supports only DAO
    Excel2000 = Supports DAO and ADO recordsets.

    Code:
    Workbooks.Add
      Application.Visible = True
      
      'PURPOSE: Field names and place them in the first
      '         row starting at "A1"
      Dim int_X As Integer
      For int_X = 0 To rs2.Fields.Count - 1
         Cells(1, int_X + 1).Value = rs2.Fields(int_X).Name
      Next
      Range("A1").CopyFromRecordset rs2
      
      'PURPOSE: Auto-fit the columns
      Cells.AutoFit
      Range("A1").Select
    Chemically Formulated As:
    Dr. Nitro

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