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