Table of Contents

VBC09345: Invalid use of property

Severity: Error  ·  Family: VBC (static semantics / abstract syntax tree)  ·  Source metadata: VBCompileErrorInfo

A property is used in a way it cannot be: assigned with Set when it can only be read, or named by a call statement.

A property that the class declares with a Property Get and no Property Set can be read, and there is nothing that sets it. A call statement calls a Sub or a Function, and a property is neither.

MS-VBA reports the same error, with the same message (recorded in Excel).

This code is raised by StatementStaticSemanticsEvaluator.

How it is raised

Situation Example Resolution
A Set of a Property Get with no Property Set. Set c.Value = Nothing Add a Property Set Value to the class.
A Set of a document module, such as ThisWorkbook or Sheet1. The host gives each of its documents a property of that name, which no Set can assign. Set Sheet1 = Nothing Assign to a variable of your own: Set ws = Sheet1.
A Set of a function, or of a property of a module, that returns neither a Variant nor an object; or of Err. Set Total = Nothing of a Function Total() As Long, Set Err = Nothing Assign to a variable of your own.
A property named by a call statement, with Call or without. t.Value, Call t.Item(1) Use its value (x = t.Value), or call a Sub or a Function.

Notes

Through an object declared As Object or Variant, the assignment or the call compiles, and raises run-time error 450 (VBR00450) when it runs. A call statement does not call the Property Get.

See also


ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca