CipherIS
asked on
MS Access Create external File
I have the below code. I am trying to create a file and write to it and its not working. Any ideas?
Dim fns As String
fns = "c:\List.txt"
Dim fso As FileSystemObject
Dim a As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set a = fso.CreateTextFile(fns, True)
a.WriteLine ("This is a test.")
a.Close
Open fns For Output As #3
Write #3, "TEST"
Close #3
And actually, it seems to work for me. It created that text file and when I open it, I see TEXT.
mx
mx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
When I say its not working I mean that C:\List.txt is not being created and as a result no text is in the file.
That is the problem I'm experiencing. I am using MS Access 2007 on Win7 computer.
That is the problem I'm experiencing. I am using MS Access 2007 on Win7 computer.
Well ... it is certainly working for me. I have noticed however that if ... some error occurs (like the file is already open) ... the error seems to be 'silent'. So, apparently some error is occurring on your system. Not sure why it's not being rendered (the error that is). Maybe some permissions / UAC issue with Win 7 ... or, is your db in a Trusted Location ?
mx
mx
ASKER
db is on my client.
I put set warnings = true but no errors are being generated and error handling is not catching anytghing.,
I put set warnings = true but no errors are being generated and error handling is not catching anytghing.,
ASKER
ok - it is creating the file but it is storing it at
C:\Users\Admin\AppData\Loc al\Virtual Store
Any idea how to get it to create on the "C:\" Drive?
C:\Users\Admin\AppData\Loc
Any idea how to get it to create on the "C:\" Drive?
Actually, it appears there is no error if the file is open ... it actually replaces the text (I changed the text). So far, I cannot really force an error.
mx
mx
ASKER
So it seems if I have a dir "C:\Test\" it will create it there but not on C:\ drive
any ideas?
any ideas?
wow. let me try this on my Win 7 machine ...
mx
mx
Well, on my Win 7 System (A2010), it puts the file in C:\ .... so ...
mx
mx
The default position for Win7 (as it was for Vista) is that you can't save into c:\. End-users would normally be running machines with this restriction in place.
Developers tend to disable any security settings, or run with sufficient admin rights to overcome things that stop them doing what they want so we don't see the problem.
To broaden the issue you will find that in WIn 7 there are lots of folders that could be accessed directly in previous versions of windows which are now inaccessible and map to virtual locations.
Developers tend to disable any security settings, or run with sufficient admin rights to overcome things that stop them doing what they want so we don't see the problem.
To broaden the issue you will find that in WIn 7 there are lots of folders that could be accessed directly in previous versions of windows which are now inaccessible and map to virtual locations.
ASKER
ok - so I will save to another location can you tell me how to modify the code so it opens the file once its done writing to it?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
mx