VBC09378 — With object must be user-defined type, Object, or Variant
Severity: Error · Family: VBC (static semantics / abstract syntax tree) ·
Source metadata: VBCompileErrorInfo
A With block is about a value that has no members.
A With block names what its .Member references are members of: an object, a record of a user-defined type, or a Variant that holds one. A number,
a String, a Boolean or a Date has no members, and neither does a project, a module or an enumeration.
MS-VBA reports the same error, with the same message (recorded in Excel).
How it is raised
| Situation | Example | Resolution |
|---|---|---|
| A variable of an intrinsic type. | Dim n As Long … With n |
Name the object or the record meant. |
| A value that is no object. | With 5, With "abc", With n + 1 |
Name the object or the record meant. |
| A project, a module or an enumeration. | With VBA, With Strings, With Color |
Qualify each member by it instead: Strings.Len(s). |
With Nothing compiles: Nothing is an object's value.
See also
⏮️ VBC09377 Expected variable or procedure, not enum type | ⏭️ VBC09379 For Each may only iterate over a collection object or an array
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca