AddFromFile Method [Access 2003 VBA Language Reference]
AddFromFile method as it applies to the References object.
The AddFromFile method creates a reference to a type library in a specified file. Reference object.
expression.AddFromFile(FileName)
expression Required. An expression that returns one of the above objects.
FileName Required String. A string expression that evaluates to the full path and file name of the file containing the type library to which you wish to set a reference.
AddFromFile method as it applies to the Module object.
The AddFromFile method adds the contents of a text file to a Module object. The Module object may represent a standard module or a class module.
expression.AddFromFile(FileName)
expression Required. An expression that returns one of the above objects.
FileName Required String. The name and full path of a text (.txt) file or another file that stores text in an ANSI format.
Remarks
As it applies to the References object.
The following table lists types of files that commonly contain type libraries.
File extension | Type of file |
---|---|
.olb, .tlb | Type library file |
.mdb, .mda, .mde | Database |
.exe, .dll | Executable file |
.ocx | ActiveX control |
As it applies to the Module object.
The AddFromFile method places the contents of the specified text file immediately after the Declarations section and before the first procedure in the module if it contains other procedures.
The AddFromFile method enables you to import code or comments stored in a text file.
In order to add the contents of a file to a form or report module, the form or report must be open in form Design view or report Design view. In order to add the contents of a file to a standard module or class module, the module must be open.
Example
As it applies to the References object.
The following example adds a reference to the Microsoft Scripting Runtime library.
References.AddFromFile "C:\WINNT\system32\scrrun.dll"
As it applies to the Module object.
The following example places the contents of the file "ShippingRoutines.bas" into the module "CalculateShipping" immediately after the Declarations section, but before the first procedure in the module.
Modules("CalculateShipping").AddFromFile "C:\Shipping\ShippingRoutines.bas"
Applies to | Module Object | References Collection