Previous  Home  Next

What's an "object model"?

Forget PowerPoint for a second. Let's talk about machines.

A machine is made of various assemblies of parts. The assemblies are made up of smaller parts which are in turn made up of even smaller parts.

Here's a typical machine:


Car is made up of lower-level assemblies:


We can break each assembly down even further. For example, Engine contains Pistons, Carburetor and so on.

It's good to know where each part or assembly fits into the whole machine when we talk about it. One way of doing that is to use an outline or "hierarchy" of parts. For example:


Notice that there are collections of similar parts: Pistons is the collection of all the pistons in Engine. The members of Pistons are the individual items, Piston1, Piston2 and so on. You'll see a little later how Collections fit into the PowerPoint object model.

You can see where everything fits into place, but if we want to talk about just the carburetor, hauling around that whole outline gets tedious. Instead, we can use a kind of shorthand:


That's short for "The Widget that's part of the Carburetor that's part of the Engine that's part of the Car". We don't know from that how everything else fits together but we can find the Widget by following the trail from Car to Engine to Carburetor and so on.

Now suppose we want to explain how to assemble a carburetor. It could easily turn into something like:

Insert the Car.Engine.Carburetor.Widget into the Car.Engine.Carburetor.Frammistat and give it half a turn.  Then attach the Car.Engine.Carburetor.Frammistat.Bracket and fasten it securely to the Car.Engine.Carburetor.Freeblemonger

Scary, eh?

But look at this:

With the Car.Engine.Carburetor
	insert the .Widget into the .Frammistat
	give it half a turn
	attach the .Frammistat.Bracket
	fasten it securely to the .Freeblemonger
You're done with Car.Engine.Carburetor

That says exactly the same thing but it's a lot easier to follow, even if you've never wielded a reverse-threaded left-handed number 12 Freeblemonger wrench in your life.

Now what's all this got to do with PowerPoint? Have a look at this:

With ActivePresentation.Slides(1).Shapes("Rectangle 1")
	.Top = 0
	.Left = 0
	.Fill.ForeColor.RGB = RGB(255,0,0)
End With

Look familiar? Even if you don't understand the details, it's pretty clear that we're working with the shape called "Rectangle 1" on Slide #1 in the presentation that's currently active. And that we're setting its position then doing something or other with its color.

Taken all together, the various bits and the way they fit together are kind of like the model engines you may have built as a kid. The PowerPoint object model is a kind of mental model of how PowerPoint is assembled.

Click Next to continue

Previous  Home  Next