|
-
Dec 12th, 2000, 08:54 AM
#1
Thread Starter
Hyperactive Member
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!
-
Dec 12th, 2000, 08:55 AM
#2
Frenzied Member
(no answer here dude, sorry)
-
Dec 13th, 2000, 10:07 PM
#3
New Member
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?
-
Dec 13th, 2000, 10:15 PM
#4
Fanatic Member
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
-
Dec 13th, 2000, 10:19 PM
#5
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|