Objects
An object is something in Excel/VBA that you can access in a program. Some objects are created automatically, and are always available. You've used one already: ThisWorkbook
. When you run code, Excel creates a ThisWorkbook
object for you, and stuffs it with useful information. You've accessed one of it's properties: Path
. As in:
Open ThisWorkbook.Path & "\" ...
The ThisWorkbook
object has a Path
property that tells you where the .xlsm
file is stored.
There are hundreds of objects in Excel. You can see them in VBE (the Visual Basic Editor). Open it, and show the object browser. Do that by pressing F2, or using the View menu.
You'll see something like this:
On the left are the types of objects that are available. Scroll down, and select ThisWorkbook
.
On the right, you'll see it's properties. There are a lot!
Choose Path
.
Click on the Help button, and your browser will show you a webpage about the property. It says:
So, ThisWorkbook
is an object. It has properties, like Path
, that give you info about it. You can use the object browser to list the properties, and get help about them.