If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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

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

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.

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

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.