469,632 Members | 1,732 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,632 developers. It's quick & easy.

Sending data to a text or Word file

I have written a small VB program which lists my music files on my computer,
but I
can't get it to print exactly the way I want it to. The data is viewed on
screen in
an MSFlexGrid named "TextGrid" and the following code will send it to a
printer, but I was hoping to be able to send it to either a text file or
directly to a Word for Windows file.

Private Sub Command34_Click()
Dim X%

For X% = 0 To TextGrid.Rows - 1
TextGrid.Row = X%
TextGrid.Col = 0
Printer.Print , TextGrid.Text;
TextGrid.Col = TextGrid.Col + 1
Printer.Print , TextGrid.Text
Next X%

End Sub

One problem with the method shown above is that the song titles are not
always correctly aligned. But I would like to be able to include some other
formatting as well, so it would be easiest to send it directly to either a
text file (which I could pick up in Word) or to a Word file.
Can anyone give me a clue as to how I go about this?

Phil Benson
Jul 17 '05 #1
7 5497
On Fri, 25 Jun 2004 13:44:23 GMT, "MouseHart" <Mo*******@trap.net>
wrote:
I have written a small VB program which lists my music files on my computer,
but I
can't get it to print exactly the way I want it to. The data is viewed on
screen in
an MSFlexGrid named "TextGrid" and the following code will send it to a
printer, but I was hoping to be able to send it to either a text file or
directly to a Word for Windows file.

Private Sub Command34_Click()
Dim X%

For X% = 0 To TextGrid.Rows - 1
TextGrid.Row = X%
TextGrid.Col = 0
Printer.Print , TextGrid.Text;
TextGrid.Col = TextGrid.Col + 1
Printer.Print , TextGrid.Text
Next X%

End Sub

One problem with the method shown above is that the song titles are not
always correctly aligned. But I would like to be able to include some other
formatting as well, so it would be easiest to send it directly to either a
text file (which I could pick up in Word) or to a Word file.
Can anyone give me a clue as to how I go about this?


It would be more sensible to send it to the Printer
- since that is where you want it to go in the end

You are missing positioning the fields
Printer.CurrentX = ....
Jul 17 '05 #2
Although the ultimate destination may be the printer, I still wonder if
there is a way to send it to a file. That information would be useful to me
for future reference, in case I wanted to export the data instead of print
it. I will take your advice on positioning the fields, though. I was not
aware of that command. Thanks.
"J French" <er*****@nowhere.com> wrote in message
news:40***************@news.btclick.com...
On Fri, 25 Jun 2004 13:44:23 GMT, "MouseHart" <Mo*******@trap.net>
wrote:
I have written a small VB program which lists my music files on my computer,but I
can't get it to print exactly the way I want it to. The data is viewed onscreen in
an MSFlexGrid named "TextGrid" and the following code will send it to a
printer, but I was hoping to be able to send it to either a text file or
directly to a Word for Windows file.

Private Sub Command34_Click()
Dim X%

For X% = 0 To TextGrid.Rows - 1
TextGrid.Row = X%
TextGrid.Col = 0
Printer.Print , TextGrid.Text;
TextGrid.Col = TextGrid.Col + 1
Printer.Print , TextGrid.Text
Next X%

End Sub

One problem with the method shown above is that the song titles are not
always correctly aligned. But I would like to be able to include some otherformatting as well, so it would be easiest to send it directly to either atext file (which I could pick up in Word) or to a Word file.
Can anyone give me a clue as to how I go about this?


It would be more sensible to send it to the Printer
- since that is where you want it to go in the end

You are missing positioning the fields
Printer.CurrentX = ....

Jul 17 '05 #3
On Sat, 26 Jun 2004 04:21:27 GMT, "MouseHart" <Mo*******@trap.net>
wrote:
Although the ultimate destination may be the printer, I still wonder if
there is a way to send it to a file. That information would be useful to me
for future reference, in case I wanted to export the data instead of print
it. I will take your advice on positioning the fields, though. I was not
aware of that command. Thanks.


Channel = FreeFile
Open "Test.dat" For Output As #Channel
For L9 = 1 To Max
Print# Channel, ItemOne; ' <- note ';'
Print# Channel, vbTab
Print# Channel, ItemTwo
Next
Close# Channel
Jul 17 '05 #4
Thanks a lot. Once again, commands I could not find in my book.

"J French" <er*****@nowhere.com> wrote in message
news:40***************@news.btclick.com...
On Sat, 26 Jun 2004 04:21:27 GMT, "MouseHart" <Mo*******@trap.net>
wrote:
Although the ultimate destination may be the printer, I still wonder if
there is a way to send it to a file. That information would be useful to mefor future reference, in case I wanted to export the data instead of printit. I will take your advice on positioning the fields, though. I was notaware of that command. Thanks.


Channel = FreeFile
Open "Test.dat" For Output As #Channel
For L9 = 1 To Max
Print# Channel, ItemOne; ' <- note ';'
Print# Channel, vbTab
Print# Channel, ItemTwo
Next
Close# Channel

Jul 17 '05 #5
On Sun, 27 Jun 2004 04:07:08 GMT, "MouseHart" <Mo*******@trap.net>
wrote:
Thanks a lot. Once again, commands I could not find in my book.


Don't you have a Help System ?

Some people use the VB5 Help file

Oddly enough I keep a backup copy of that file at:

www.jerryfrench.co.uk/utils/vb5help.zip (all lowercase)


Jul 17 '05 #6
Thanks again, and no, I don't have the VB6 Help files. The Enterprise
Edition requires separate purchase of the MSDN collection, and I don't have
it. I appreciate the use of the VB5 Help, however. I'm sure it will be
fine for anything I need (until I actually learn what I'm doing, which could
be quite a while).

"J French" <er*****@nowhere.com> wrote in message
news:40****************@news.btclick.com...
On Sun, 27 Jun 2004 04:07:08 GMT, "MouseHart" <Mo*******@trap.net>
wrote:
Thanks a lot. Once again, commands I could not find in my book.


Don't you have a Help System ?

Some people use the VB5 Help file

Oddly enough I keep a backup copy of that file at:

www.jerryfrench.co.uk/utils/vb5help.zip (all lowercase)

Jul 17 '05 #7
> Thanks again, and no, I don't have the VB6 Help files. The Enterprise
Edition requires separate purchase of the MSDN collection, and I don't have it.


Unless something has changed (and I doubt it has), the Enterprise
Edition of Visual Basic (as well as Visual Studio) comes with the MSDN
files on a separate set of CD's; you should have gotten them with your
purchase. You can view the entire MSDN online at this link...

http://msdn.microsoft.com/library/default.asp

Specifically, open the "tree" to this...

Visual Tools and Languages
Visual Studio 6.0
Visual Basic 6.0
Product Documentation
Reference
Language Reference

The direct link to the Reference branch (Language Reference is under
this) is...

http://msdn.microsoft.com/library/en...LROverview.asp

The direct link to the Visual Studio 6.0 branch is...

http://msdn.microsoft.com/library/en.../vb6anchor.asp

Rick - MVP

Jul 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by MouseHart | last post: by
9 posts views Thread by Miro | last post: by
reply views Thread by Andrea | last post: by
13 posts views Thread by liujiaping | last post: by
1 post views Thread by the_ricka | last post: by
2 posts views Thread by Alex Bryan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.