Table of Contents

VBC09345 — Invalid use of property

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

A property that can only be read is assigned with Set.

The class declares a Property Get of that name and no Property Set: the property can be read, and there is nothing that sets it.

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.

Notes

Through an object declared As Object or Variant, the assignment compiles, and raises error 450 when it runs.

See also


⏮️ VBC09344 RSet allowed only on strings | ⏭️ VBC09346 Assignment to constant not permitted


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