DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    CB Green Guest

    Creating text file


    i am creating a text file so that it can imported into excel but everytime
    i get the path it tells me that it cannot be found here is an example of
    the code

    strFileName = Date & ".txt"
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set txtfile = fso.createtextfile(frmReportSelection.Dir1.Path & strFileName,
    True)

    any help is most appreciated


  2. #2
    Russ Guest

    Re: Creating text file


    "CB Green" <c_unique@msn.com> wrote:
    >
    >i am creating a text file so that it can imported into excel but everytime
    >i get the path it tells me that it cannot be found here is an example of
    >the code
    >
    >strFileName = Date & ".txt"
    > Set fso = CreateObject("Scripting.FileSystemObject")
    > Set txtfile = fso.createtextfile(frmReportSelection.Dir1.Path & strFileName,
    >True)
    >
    >any help is most appreciated
    >


    CB,
    It looks like you are missing a slash between the path and the filename.
    Try:

    Set txtfile = fso.createtextfile(frmReportSelection.Dir1.Path & "\" & strFileName,
    True)

    HTH,
    -Russ.


  3. #3
    CB Green Guest

    Re: Creating text file


    "Russ" <russell.thompson@adlink.com> wrote:
    >
    >"CB Green" <c_unique@msn.com> wrote:
    >>
    >>i am creating a text file so that it can imported into excel but everytime
    >>i get the path it tells me that it cannot be found here is an example of
    >>the code
    >>
    >>strFileName = Date & ".txt"
    >> Set fso = CreateObject("Scripting.FileSystemObject")
    >> Set txtfile = fso.createtextfile(frmReportSelection.Dir1.Path & strFileName,
    >>True)
    >>
    >>any help is most appreciated
    >>

    >
    >CB,
    >It looks like you are missing a slash between the path and the filename.
    >Try:
    >
    > Set txtfile = fso.createtextfile(frmReportSelection.Dir1.Path & "\" &

    strFileName,
    >True)
    >
    >HTH,
    >-Russ.
    >

    thanks Russ
    I had tried that first becuase i had a text box for the user to type the
    path but that didn't work, so i added a directory windows so that they could
    pick it out of there and that didn't work either.



  4. #4
    Russ Guest

    Re: Creating text file


    >thanks Russ
    >I had tried that first becuase i had a text box for the user to type the
    >path but that didn't work, so i added a directory windows so that they could
    >pick it out of there and that didn't work either.
    >
    >


    What do you get when you do this:

    Debug.Print frmReportSelection.Dir1.Path & strFileName

    -Russ.

  5. #5
    CB Green Guest

    Re: Creating text file


    "Russ" <russell.thompson@adlink.com> wrote:
    >
    >>thanks Russ
    >>I had tried that first becuase i had a text box for the user to type the
    >>path but that didn't work, so i added a directory windows so that they

    could
    >>pick it out of there and that didn't work either.
    >>
    >>

    >
    >What do you get when you do this:
    >
    > Debug.Print frmReportSelection.Dir1.Path & strFileName
    >
    >-Russ.

    When i did that i first got c:
    then i did
    debug.print frmreportselection.txtinfo3.text &"\"& strfilename and it gave
    me
    c:\07272000.txt
    do you think i am missing a reference i check that everything should be there

    thanks again for your assistance

  6. #6
    Russ Guest

    Re: Creating text file


    >>What do you get when you do this:
    >>
    >> Debug.Print frmReportSelection.Dir1.Path & strFileName
    >>
    >>-Russ.


    >When i did that i first got c:
    >then i did
    >debug.print frmreportselection.txtinfo3.text &"\"& strfilename and it gave
    >me
    >c:\07272000.txt
    >do you think i am missing a reference i check that everything should be

    there
    >
    >thanks again for your assistance


    CB,
    Just to clear things up a bit, when you say you "added a directory windows",
    do you mean that you added a DirListBox control? If so, and strFileName
    contains "07272000.txt", then to create the file in the right directory,
    your code should look like:

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set txtfile = fso.createtextfile( _
    frmReportSelection.Dir1.Path & "\" & strFileName,True)

    This will create a file as something like:

    c:\SomeDir\SomeSubDir\07272000.txt


    Without the "\", VB will happily create your file as:

    c:\SomeDir\SomeSubDir07272000.txt

    HTH,
    -Russ.




  7. #7
    CB Green Guest

    Re: Creating text file


    "Russ" <russell.thompson@adlink.com> wrote:
    >
    >>>What do you get when you do this:
    >>>
    >>> Debug.Print frmReportSelection.Dir1.Path & strFileName
    >>>
    >>>-Russ.

    >
    >>When i did that i first got c:
    >>then i did
    >>debug.print frmreportselection.txtinfo3.text &"\"& strfilename and it gave
    >>me
    >>c:\07272000.txt
    >>do you think i am missing a reference i check that everything should be

    >there
    >>
    >>thanks again for your assistance

    >
    >CB,
    >Just to clear things up a bit, when you say you "added a directory windows",
    >do you mean that you added a DirListBox control? If so, and strFileName
    >contains "07272000.txt", then to create the file in the right directory,
    >your code should look like:
    >
    > Set fso = CreateObject("Scripting.FileSystemObject")
    > Set txtfile = fso.createtextfile( _
    > frmReportSelection.Dir1.Path & "\" & strFileName,True)
    >
    >This will create a file as something like:
    >
    > c:\SomeDir\SomeSubDir\07272000.txt
    >
    >
    >Without the "\", VB will happily create your file as:
    >
    > c:\SomeDir\SomeSubDir07272000.txt
    >
    >HTH,
    >-Russ.
    >
    >
    >

    Russ thatnks fo your help

    can i write nulls to a file or do i have to chane it to a blank " " space?

    i missed the obvious error
    this was my file name

    strfilename=date & ".txt"

    which you know vb's date structure

    07/25/2000.txt and that was what was genrating the error

    thanks for your patience




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links