Save VBA code to text

<< Click to Display Table of Contents >>

Navigation:  VBA >

Save VBA code to text

 

Exporting a VBA Module to a Text File  

 

Your VBA modules and class modules are the only objects in the database for which you can use a menu to save as text and recover from text.
 

1.Open the Database window (of any database with code).

2.Select Modules.

3.Select an individual module.

4.Choose File Ø Export.

5.Save the file as a text (*.txt).

6.Select your folder and file name.

7.Select the Autostart check box and click Export.

Your VBA module will now be saved in a text file. In Access 2000 and later, you can also export modules from within the Visual Basic Editor. First, you need to select the object that you want to export in the Project Explorer, then you choose File Ø Export, and the steps are similar to the preceding procedure. If you use the Visual Basic Editor to save the code, you can use more specific file types like *.BAS and *.CLS rather than *.TXT.

 

Importing the VBA Text File Back into the Database

In Access 97, the only way to import the VBA text file back into the database is to open the text file in a text editor like Notepad, select all, copy to the paste buffer, open a new module in Access, and paste the code into the new module. You can use this simple method in all versions of Access.

In Access 2000 and later, however, you can also import the VBA text file directly into the database by following these steps:

1.Open a new database.

2.Open the Visual Basic Editor (press ALT+F11).

3.Choose File Ø Import File.

4.Find the file and click Open.

5.You will now find the module in the Project Explorer. If it is not visible, choose View Ø Project Explorer.

 

Other Pages you may like

Stop Compile Error Prompt in VBA