Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File not found - open "filename" for output as 1 (VBA Excel)

Status
Not open for further replies.

Karja

Programmer
Apr 20, 2006
43
LU
Hello there,

system: VBA Microsoft Office 2003, win XP SP2

I've got a very strange problem and I was wondering if somebody of you could help. Suddeny a VBA program does not work anymore. It stops at the following line:

Open "Datafile.txt" For Output As #1

Then the system comes up with 'file not found'. Strange because it worked before. The system should of course create the file.

- I have the proper rights (I can create the file manually)
- other macro's run fine
- I also does not work with existing files

Anyone a clue? Every help appreciated!
Regards Karja,
 



Hi,

How about including the path and filename in the open statement?

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Thanks for the tip. But I already tried those things (should have mentioned it, though. But that is not the problem...
 
What is the value returned by the CurDir function when the error raises ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 


Use the FreeFile function to assign the channel.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Hello again. Thanks for the reply's. Now this is my actual code an it still does not work :-(

Const OutputFile As String = "c:\Incasso.txt"
hFile = FreeFile: Open OutputFile For Output As hFile

The current dir is
C:\Documents and Settings\user\My Documents
(but this should not matter as I entered the path

This problem realy gives me the creeps. This seems to be the same problem: (i've no account) :)
 
You have sufficient permissions to create a file in the root directory ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Yes, I do. I am local administrator. The problem occurs with every directory I am trying. At home (where I am now, it also does not work). I can create manual files in alle directories, so I am absotely sure I have sufficient permission)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top