AddFromFile Method

Applies To

CodeModule object, References collection.

Description

For the References collection, adds a reference to a project from a file. For the CodeModule object, adds the contents of a file to a module.

Syntax

object.AddFromFile(filename)

The AddFromFile syntax has these parts:

Part

Description

object

Required. An object expression that evaluates to an object in the Applies To list.

filename

Required. A string expression specifying the name of the file you want to add to the project or module. If the file name isn't found and a path name isn't specified, the directories searched by the Windows OpenFile function are searched.


Remarks

For the CodeModule object, the AddFromFile method inserts the contents of the file starting on the line preceding the first procedure in the code module. If the module doesn't contain procedures, AddFromFile places the contents of the file at the end of the module.

See Also

Add method, AddFromGuid method, AddFromString method, ItemAdded event, ItemRemoved event, Remove method.

Example

The following example uses the AddFromFile method to add the contents of a file to a specified code pane.

Application.VBE.CodePanes(3).CodeModule.AddFromFile "c:\Code Files\book2.frm"