I would like to check which objects are selected/active.
In PowerPoint and Word it is quite easy, but in Excel... nothing what I checked is working. Globals.ThisAddin.ActiveWindow.Selection is of type: dynamic. I added reference to VisualBasic, to have an access to TypeName function.
If chart is selected it returns type "ChartObject"... so I am setting it to variable of ChartObject type, but then I have no access to almost any of its properties and methods, for example when I try to read name that object or trying to return chart from it gives me an error.
When there is few shapes selected then TypeName function returns me type: "DrawingObjects"... but I am not able to read anything from it. I was trying to get get from it ShapeRange, but again... errors.
Could you advise me how to get all selected objects?
In Excel VBA TypeName() can return any of a large variety of names corresponding to a variety of Shapes.
Once we have determined that the Name (as defined by TypeName()) corresponds to a specific Shape-type, we can use the
Name
ofSelection
to define that specific Shape:Now that
sh
has been bothDimmed
andSet
we can get all it Properties and use all its Methods.I managed to create code that works (for charts):