Documentation Center

With Statement

Subroutines often need to perform several different actions on the same object.

One way is to use several statements:

PSL.Projects(1).SourceLists(1).String(1).State(pslStateReadOnly) = True
PSL.Projects(1).SourceLists(1).String(1).Comment = "Set to read only"

This is easier to read, and more efficient, using the With statement:

With PSL.Projects(1).SourceLists(1).String(1)
  .State(pslStateReadOnly) = True
  .Comment = "Set to read only"
End With

The object reference can be a reference to a collection.