PowerPoint: DrawLine

Tags: vsto, office, powerPoint

We came across the question how invoke the command to draw a simple line in PowerPoint.
Starting from PowerPoint 2007 where the Ribbon influences the Userinterface in Office, normally you would do it by calling a function “ExecuteMso” on the Application.CommandBars collection.

The following code starts drawing a Rectangle:

Globals.ThisAddIn.Application.CommandBars.ExecuteMso("ShapeRectangle");
The funny thing is – the original question was how to invoke the draw line command.
Normally you would think the IdMso command name for this action would be named “ShapeLine”.
But unfortunately not in Office. Somehow the command name for it is called: “ShapeStraightConnector”, so the correct command for it would be:
Globals.ThisAddIn.Application.CommandBars.ExecuteMso("ShapeStraightConnector");

No idea why they gave them that name. Anyhow – the Resoucres to find the corresponding idMso Control Ids are these two downloads that every serious Office Developer should have already downloaded and installed on their PC:

If you have questions regarding Office Add-In development the first point to ask is in the MSDN VSTO Forum.
In case you need support, training, consulting or a prototype for VSTO and Office Add-Ins, feel free to ask X4U for a specialist.

Greets – Helmut

 
Add a Comment