Edit

Share via


Application.SaveAsText

Applies to: Access 2024, Access 2019

The Application.SaveAsText method in Microsoft Access allows you to export database objects (like forms, reports, macros, modules, or queries) into a text file. This can be useful for version control, debugging, or transferring objects between databases.

Syntax

Application.SaveAsText ObjectType, ObjectName, FileName

Parameters

Parameter Description
ObjectType The type of object you want to export (e.g., acForm, acReport, acQuery, etc.).
ObjectName The name of the object you want to export.
FileName The full path and name of the text file where the object will be saved.

Example

Here’s how you can save a form named "MyForm" to a text file:

Application.SaveAsText acForm, "MyForm", "C:\Exports\MyForm.txt"

Remarks

The exported text file contains all the properties and definitions of the object. You can later use the Application.LoadFromText method to import the object back into a database. This method is particularly useful for developers who want to integrate Access objects into version control systems or share objects in a readable format.