melodic_agony
New Member
- Joined
- Aug 30, 2017
- Messages
- 2
I'm using File System Object to create a text file but when I run the code I'm getting a runtime error that I don't recognize. Code works fine if the text file exists and it just executes and overwrites the existing file.
The code is:
Sub main()
Dim fso As FileSystemObject
Dim Fileout As Object
...
'Create log file.
Set fso = CreateObject("Scripting.FileSystemObject")
Set Fileout = fso.CreateTextFile("c:\ConfigErrorLog.txt", True)
When run (without the file already existing), VBA throws:
"Run-time error '-2147023582... etc'
Method 'CreateTextFile' of object 'IFileSystem3' failed"
and sits on that last line of code.
Does anyone know what could cause this?
The code is:
Sub main()
Dim fso As FileSystemObject
Dim Fileout As Object
...
'Create log file.
Set fso = CreateObject("Scripting.FileSystemObject")
Set Fileout = fso.CreateTextFile("c:\ConfigErrorLog.txt", True)
When run (without the file already existing), VBA throws:
"Run-time error '-2147023582... etc'
Method 'CreateTextFile' of object 'IFileSystem3' failed"
and sits on that last line of code.
Does anyone know what could cause this?