Sending data to a text or Word file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MouseHart

    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


  • J French

    #2
    Re: Sending data to a text or Word file

    On Fri, 25 Jun 2004 13:44:23 GMT, "MouseHart" <MouseHart@trap .net>
    wrote:
    [color=blue]
    >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?[/color]

    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.Current X = ....


    Comment

    • MouseHart

      #3
      Re: Sending data to a text or Word file

      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" <erewhon@nowher e.com> wrote in message
      news:40dc3aa3.2 4857412@news.bt click.com...[color=blue]
      > On Fri, 25 Jun 2004 13:44:23 GMT, "MouseHart" <MouseHart@trap .net>
      > wrote:
      >[color=green]
      > >I have written a small VB program which lists my music files on my[/color][/color]
      computer,[color=blue][color=green]
      > >but I
      > >can't get it to print exactly the way I want it to. The data is viewed[/color][/color]
      on[color=blue][color=green]
      > >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[/color][/color]
      other[color=blue][color=green]
      > >formatting as well, so it would be easiest to send it directly to either[/color][/color]
      a[color=blue][color=green]
      > >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?[/color]
      >
      > 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.Current X = ....
      >
      >[/color]


      Comment

      • J French

        #4
        Re: Sending data to a text or Word file

        On Sat, 26 Jun 2004 04:21:27 GMT, "MouseHart" <MouseHart@trap .net>
        wrote:
        [color=blue]
        >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.[/color]

        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


        Comment

        • MouseHart

          #5
          Re: Sending data to a text or Word file

          Thanks a lot. Once again, commands I could not find in my book.

          "J French" <erewhon@nowher e.com> wrote in message
          news:40dd2342.8 4416908@news.bt click.com...[color=blue]
          > On Sat, 26 Jun 2004 04:21:27 GMT, "MouseHart" <MouseHart@trap .net>
          > wrote:
          >[color=green]
          > >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[/color][/color]
          me[color=blue][color=green]
          > >for future reference, in case I wanted to export the data instead of[/color][/color]
          print[color=blue][color=green]
          > >it. I will take your advice on positioning the fields, though. I was[/color][/color]
          not[color=blue][color=green]
          > >aware of that command. Thanks.[/color]
          >
          > 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
          >
          >[/color]


          Comment

          • J French

            #6
            Re: Sending data to a text or Word file

            On Sun, 27 Jun 2004 04:07:08 GMT, "MouseHart" <MouseHart@trap .net>
            wrote:
            [color=blue]
            >Thanks a lot. Once again, commands I could not find in my book.[/color]

            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)




            Comment

            • MouseHart

              #7
              Re: Sending data to a text or Word file

              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" <erewhon@nowher e.com> wrote in message
              news:40de7a92.1 72318621@news.b tclick.com...[color=blue]
              > On Sun, 27 Jun 2004 04:07:08 GMT, "MouseHart" <MouseHart@trap .net>
              > wrote:
              >[color=green]
              > >Thanks a lot. Once again, commands I could not find in my book.[/color]
              >
              > 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)
              >
              >
              >
              >[/color]


              Comment

              • Rick Rothstein

                #8
                Re: Sending data to a text or Word file

                > Thanks again, and no, I don't have the VB6 Help files. The Enterprise[color=blue]
                > Edition requires separate purchase of the MSDN collection, and I don't[/color]
                have[color=blue]
                > it.[/color]

                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...



                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...

                Gain technical skills through documentation and training, earn certifications and connect with the community


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

                Gain technical skills through documentation and training, earn certifications and connect with the community


                Rick - MVP

                Comment

                Working...