I am writing a VBA code in an Excel spreadsheet. The code tested OK and now it's time to output the results to an ASCII (text) file - as this has been the very intent of the code since the very beginning. I've done this dozens of times in the past. To make extra sure (memory blanks out sometimes), I google-checked the "Open" command to open a file and associate it to a file number. It all seems alright - and yet the spreadsheet doesn't even create the output file, let alone output something to it. Here's what I'm doing; the Print #1 command was placed as an output text and so far it's the only output-to-file command in the whole code.
Sub Driver()
[... Lines of code ...]
' Open the file for output
Open "WriteADIF.txt" For Output As #1
Print #1, "Hello"
[... Lines of code ...]
Close #1
End Sub
The programs runs fine till the end, no error message is issued and yet no "WriteADIF.txt" file is created. It should find it in the same folder where the Excel sheet is stored, but it is not there. This is so baffling I don't know what to say or do. Could this be some kind of security issue? For example, Excel is not set as a trusted source for writing files to the disk? The folder is not system-protected, it's an ordinary C:\Users... type one.
Any ideas?
Open ThisWorkbook.Path & "\WriteADIF.txt" For Output As #1Debug.Print CurDirprints the current directory to the Immediate window.