How do I send MSFlexGrid data to a tab-delimited text file in VB6 so that all the columns remain aligned?
I want to send the data from VB6 MSFlexGrid1 to a tab-delimited text file and preserve the column alignments. Anyone know how to do this? Thanks for any help...
Ok, first, tab delimited text files won't look like the columns are aligned unless you open in an app like Excel that can show columns properly. Is that what you expect?
Regarding the flexgrid, is your data based on a record set or data you manually pushed into the control?
BrianVSoft
Kbirecki is correct.. Tabs in a plain text file don't automatically present the text in columns. Only the application used to view the text file can use the tabs to attempt to display it in columns.
Excel won't do it directly, you have to import the file into excel and confirm that it is a TAB file.
Other Apps like Wordpad still require you to set TAB widths manually..
What do you plan to use this file for? A Printed Report? or to email this file as an Invoice or Report?
This might help the ExEx folk give you some specific advice..
jazjef
ASKER
I would like it to be printable---but viewable as a text file type report so you don't need Excel in order to view it. The data would be manually pushed/entered into the control----there would be no recordset or datasource feeding it. What about the DataReports feature? Could you feed it from an MSFlexGrid? Are there any add-ons that will take the data of a grid and generate a simple report that you know of. Thanks for the responses.....
The MSFlexGrid is a display element. I think whatever your source is should be the source for any other output. Otherwise you;d have to write something that parses the contents of the flexgrid to spit them back out somewhere. If you have the data to put into the flexgrid, just use that to push to your output format.
As for a text file output in columns, you also have to think about whether the viewer is using a monospace font or not. Monospace fonts allow you to display text in columns, but only if you can be sure the recipient is using a viewer that is showing in monospace.
BrianVSoft
By using Printer.CurrentX and Printer.CurrentY you can print each cell text to exact column widths. You can even print vertical lines between the columns and a box around the whole format..
Then, by using one of the free PDF printer apps, you can direct that same printout to a PDF file which can be viewed by most PC users. The viewer is freely available.
That's pretty elaborate vbclassicguy.... over my head; I don't know if I can implement that. I was thinking about something like this.... it will print an msflexgrid but without a vbcrlf somewhere if you print more than 1 then they print on top of each other. This will send an msflexgrid to Primo PDF or my HP Laserjet printer....
Set Printer = Printers(0)
Printer.PaintPicture grd_VisStats.Picture, 0, 0
Printer.EndDoc
jazjef
ASKER
Nice solution VBClassicGuy... major-league coding. I have included another method I got to work in case anyone following this post is interested. Thanks to all....
Regarding the flexgrid, is your data based on a record set or data you manually pushed into the control?