VBA Object Required
When you work in the VBA programming language -- Visual Basic for Applications -- you may encounter the error statement "Object Required." This means your command made a reference to a property or a method associated with a VBA software object, but you didn't specify which object you meant.
-
Objects
-
Objects in programming languages are parts of an application such as a list, a checkbox, a form, a worksheet, a button or even a single character. You can gather multiple VBA objects of the same type -- a half-dozen forms used in the same application, for example -- together into a collection object. By modifying or manipulating a collection, you affect all the objects in that collection at once. The tools for doing this are usually properties and methods.
Properties
-
Properties are a software object's attributes. If the object is a document, its properties include its name, its content and whether the current content has been saved. The properties of cells in a grid might include the numerical value assigned to each cell. Methods are activities that objects perform: If a document is the object, you use the "PrintOut" method to direct the computer to print it. VBA ranks objects in a hierarchy, and lower-ranked objects such as "Color" or "Value" can become properties of higher-ranked objects.
-
Object Required
-
Properties and methods have to be attached to VBA objects. If you try working with properties or methods without an attached object, "Object Required" pops up -- the equivalent of hitting "Print" without identifying a document. Once you attach an object to the property you want to work with, that should solve the problem. If you still get the message, check that you're spelling the name of the property correctly.
Considerations
-
Sometimes you keep getting the error message even after you specify the object and confirm the spelling. The next step is to see if the object is visible from the part of the program where you refer to it. If accessing the object requires using a File Open command, look at the command and see if it uses the correct arguments. If nothing else works, check the object's documentation and make sure the action you're asking for is valid -- for instance, that the property you're referencing is a property of the object.
-