Search notes:

VBA statement: open

open can be used to open a file for reading or writing.
Use freeFile to determine the next »file descriptor« for open.

open for output

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
Github repository about-VBA, path: /language/statements/open/open-for-output.bas

See also

The print# statement.
The open statement and character encodings
GetTempFileName to create a name for temporary files.
The functions in the File module, especially slurpFile (which reads an entire file into a string) and its corresponding flushToFile.
VBA statements

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1740089896, '3.142.35.211', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/VBA/language/statements/open/index(67): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78