Name
With Statement
Syntax
Withobject[statements] End With
objectUse: Required
Data Type: Object
A previously declared object variable.
statementsUse: Optional
Program code to execute against object.
Description
Performs a set of property assignments and executes other code against a particular object, thus allowing you to refer to the object only once. Because the object is referred to only once, the “behind the scenes” qualification of that object is also performed only once, leading to improved performance of the code block.
Rules at a Glance
The single object referred to in the
Withstatement remains the same throughout the code contained within theWith...EndWithblock. Therefore, only properties and methods ofobjectcan be used within the code block without explicitly referencing the object. All other object references within theWith...Endstatement must start with a fully qualified object reference.Withstatements can be nested, as long as the innerWithstatement refers to a child object or a dependent object of the outerWithstatement.
See Also
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access