Modules Method

Applies To

Application Object, Workbook Object.

Description

Accessor. Returns an object that represents a module (a Module object, Syntax 1) or a collection of all modules (a Modules object, Syntax 2) in the workbook. Read-only.

Syntax 1

object.Modules(index)

Syntax 2

object.Modules

object

Required. The Workbook object.

index

Required for Syntax 1. The name or number of the module to return.

Example

This example creates a new Visual Basic module in the active workbook and then inserts the file TESTCODE.TXT into the new module.


Set newModule = Modules.Add
newModule.InsertFile fileName:="testcode.txt"