Folder.CreateTextFile Method (VB6)

Named Arguments

Yes

Syntax

oFolderObj.CreateTextFile FileName[, Overwrite[, _
           Unicode]])

oFolderObj

Use: Required

Data Type: Folder object

Any object variable returning a Folder object.

FileName

Use: Required

Data Type: String

Any valid filename and optional path.

Overwrite

Use: Optional

Data Type: Boolean

Flag to indicate if an existing file of the same name should be overwritten.

Unicode

Use: Optional

Data Type: Boolean

Flag to indicate if file is to be written in Unicode or ASCII.

Return Value

A TextStream object

Description

Creates a new file at the specified location and returns a TextStream object for that file.

Rules at a Glance

  • Wildcard characters aren't allowed in FileName.

  • The default value for Overwrite is False.

  • If Unicode is set to True, a Unicode file is created; otherwise it's created as an ASCII text file.

  • The default value for Unicode is False.

Programming Tips and Gotchas

  • The newly created text file is automatically opened only for writing. If you subsequently wish to read from the file, you must first close it and reopen it in read mode.

  • You must use the Set statement to assign the TextStream object to a local object variable.

  • The CreateTextFile method in the Folder object is identical in operation to that in the FileSystemObject object.

See Also

FileSystemObject.CreateTextFile Method

Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.