Results 1 to 12 of 12
  1. #1
    Join Date
    Jan 2009
    Location
    Ohio, United States
    Posts
    167

    Unanswered: Error writing line to FSO Text File

    I'm having some trouble with a section of code used to write a response string to a text file. It worked well but when I transfered it over to my brother's computer, it was getting an error when it tried to write to the text file. I checked the references and they all were found. I wasn't sure if it would change anything that my brother is running vista and I'm on XP. Not sure if it would have some difficulty writing to the application project path.

    Here is the part of the code that is not working, the debug stops on the line "a.WriteLine (Response)". Does anyone have any ideas on what I'm doing wrong? I moused over "Response" in debug and it looked like it was pulling the correct response text. Thanks, Joshua

    Code:
    'THIS GETS THE RESPONSE
        Dim Response As String
        Response = API.ResponseText
    
    'THIS WRITES THE RESPONSE TO A TEXT FILE IN THE SAME
    'LOCATION AS THIS DB. FILE CALLED "AmazonTempText1.txt"
        Set fs = CreateObject("Scripting.FileSystemObject")
            Set a = fs.CreateTextFile(Application.CurrentProject.Path & "\AmazonTempText1.txt", True) 'True for overwrite
            a.WriteLine (Response)
            a.Close
    Last edited by scrtchmstj; 07-29-09 at 09:14.

  2. #2
    Join Date
    Jan 2009
    Location
    Ohio, United States
    Posts
    167
    Also...
    I had put the database on my brother's desktop. When I ran the module it created the text file on the desktop, like it should have, however, the text file was blank. Also I created it in Access 2002 but my brother is running 2003. Wouldn't think it would be this as it ran fine on my home computer which has 2007. Not sure if VBA is confused by vista's file management. I know I am. Cheers, Joshua

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    What is the error?
    Are you late binding here? If so, have you checked the scripting runtime library is properly referenced?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Jan 2009
    Location
    Ohio, United States
    Posts
    167
    Quote Originally Posted by pootle flump
    What is the error?
    Are you late binding here? If so, have you checked the scripting runtime library is properly referenced?
    I checked the references on my brother's computer and none showed "Missing:..." I don't think I really understand what late binding is. I did find some people at vbforums.com who were encountering a similar issue in VB writing to a Vista desktop. One user suggested it might be a "protected filesystem location that is not virtualized". I guess I could have my program write and read the text file from a static location like C:\ as it will be writing, importing and deleting the file anyways. However, I was hoping to keep in in the same location as the database. If you have any suggestions I'd love to hear them.

    Thanks for your help,
    Joshua

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Code:
    Sub testFSO()
    
    'THIS GETS THE RESPONSE
        Dim Response As String
        Response = "this text" 'API.ResponseText
        
        Dim a As Scripting.TextStream
        Dim fs As Scripting.FileSystemObject
        
    'THIS WRITES THE RESPONSE TO A TEXT FILE IN THE SAME
    'LOCATION AS THIS DB. FILE CALLED "AmazonTempText1.txt"
        Set fs = CreateObject("Scripting.FileSystemObject")
            Set a = fs.CreateTextFile(Application.CurrentProject.Path & "\AmazonTempText1.txt", True) 'True for overwrite
            a.WriteLine (Response)
            a.Close
            
    End Sub
    Can you compile and run the above?

    Late binding and early binding are a bit beyond some forum posts - just google them if you are interested.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    a possible issue is developing in A2007 but deploying in A2003/3, its never a good idea to develop in a higher version than the live application environment
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I've tested this developed in 2007 and run in 2007. I am 99% sure nothing has changed with the scripting runtime.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  8. #8
    Join Date
    Jan 2009
    Location
    Ohio, United States
    Posts
    167
    I compiled and ran (On computer running Access 2002, XP). It ran fine and exported the text file AmazonTempText1.txt to the same file path as the database. When opened it showed "this text". It was doing this correctly before writing the tab-delimited string to the text file. The problem was on the Vista side, it would not write to the created textfile. I won't be able to run any tests on Vista until later. Joshua

  9. #9
    Join Date
    Jan 2009
    Location
    Ohio, United States
    Posts
    167
    Quote Originally Posted by healdem
    a possible issue is developing in A2007 but deploying in A2003/3, its never a good idea to develop in a higher version than the live application environment
    This was developed in the 2002 version on XP machine - Runs fine
    Tested on 2003 version Vista - Creates text file but does not write to
    Tested on 2007 version XP - Runs fine

    It seems like it would be something confusing the file system path, or maybe its a security setting. Would think if the latter, it would not even create the text file.

    Thanks, Joshua

  10. #10
    Join Date
    Jan 2009
    Location
    Ohio, United States
    Posts
    167
    Has nobody encountered this yet?

  11. #11
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    as poots has suggested it may well be to do with uyser permissions.. were there any differences in user privileges between the vista that worked and the one that didn't
    I'd rather be riding on the Tiger 800 or the Norton

  12. #12
    Join Date
    Jan 2009
    Location
    Ohio, United States
    Posts
    167
    It has never worked for me on Vista. I don't see how user permission would play a part in this. It is creating the text file but is not writing to it correctly. It did write correctly when run in XP. When I tested this on his computer it was on the desktop and was running under windows administrator login.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •