PDA

View Full Version : Determining the type of object selected or created



tbaker818
08-28-2015, 02:49 PM
Whenever possible, I'd like to define object variables as their specific type and not have to resort to the generic Object. Since I'm new to the PowerPoint object model, it really slows me down when I can't use the Intellisense. I haven't found a way to definitively determine an object's type, either through the documentation, or when I'm backing into the variable via the Selection property:

Dim shShape as Shape

Set pptScaleBreakPres = appPPT.Presentations.Open("C:\Users\516785\Documents\Missed Milestones Visual\Scale Break Graphic.pptx")
Set shShape = appPPT.ActiveWindow.Selection

Using the above code, if I create a Watch on shShape, it will often say the Type is "Object/Shape" and yet, if I try to define it as a Shape, I'll get a Type Mismatch.

John Wilson
08-29-2015, 11:45 AM
Set shShape = appPPT.ActiveWindow.Selection.ShapeRange(1)

You can use this to get the type

msgbox TypeName(ActiveWindow.Selection.ShapeRange(1))

NOTE unlike Excel

msgbox TypeName(ActiveWindow.Selection)

will always return selection

tbaker818
08-31-2015, 11:31 AM
Perfect, Thanks!