open can be used to open a file for reading or writing. open. sub writeToFile()
open environ("TEMP") & "\vba-file-test.txt" for output as #1
print #1, "Hello world"
print #1, "Second line"
close #1
end sub
print# statement. open statement and character encodings File module, especially slurpFile (which reads an entire file into a string) and its corresponding flushToFile.