PPPTools Reference (AdvancedScriptHelper)
ppptools is the only script variable that provides access to PowerPoint. All methods are called on the instance — no new, no direct COM access required.
Slide
SlideWidth / SlideHeight
float w = ppptools.SlideWidth; // e.g. 720f (points)
float h = ppptools.SlideHeight; // e.g. 540f (points)
Width and height of the active slide in points (1 point = 1/72 inch). For centering:
float left = (ppptools.SlideWidth - shapeWidth) / 2f;
float top = (ppptools.SlideHeight - shapeHeight) / 2f;
Creating shapes
AddShape(type, x, y, w, h)
dynamic oShape = ppptools.AddShape(MsoAutoShapeType.msoShape8pointStar, 100f, 80f, 200f, 200f);
Adds an AutoShape to the active slide. All available types with examples: → AutoShape Types (MsoAutoShapeType)
Full Microsoft reference: MsoAutoShapeType on learn.microsoft.com
| Parameter | Type | Description |
|---|---|---|
type |
MsoAutoShapeType |
Shape type |
x |
float |
Left position in points |
y |
float |
Top position in points |
w |
float |
Width in points |
h |
float |
Height in points |
AddRect(x, y, w, h)
dynamic oRect = ppptools.AddRect(50f, 50f, 200f, 150f);
Shorthand for AddShape(msoShapeRectangle, ...).
AddOval(x, y, w, h)
dynamic oCircle = ppptools.AddOval(100f, 100f, 80f, 80f); // 80×80 circle
Shorthand for AddShape(msoShapeOval, ...). For an exact circle: w == h.
BuildFreeform(editingType, x, y)
var ffb = ppptools.BuildFreeform(MsoEditingType.msoEditingCorner, 100f, 50f);
ffb.AddNodes(MsoSegmentType.msoSegmentLine, MsoEditingType.msoEditingCorner, 200f, 50f);
ffb.AddNodes(MsoSegmentType.msoSegmentLine, MsoEditingType.msoEditingCorner, 150f, 150f);
var oTriangle = ffb.ConvertToShape();
Starts a freeform builder. Returns a FreeformBuilder object with .AddNodes(...) and .ConvertToShape() methods.
| Parameter | Type | Description |
|---|---|---|
editingType |
MsoEditingType |
msoEditingCorner (sharp corners) or msoEditingAuto (curves) |
x, y |
float |
Start point of the first node |
AddPolygon(xs, ys)
dynamic oShape = ppptools.AddPolygon(
new float[] { 100f, 200f, 150f }, // X coordinates
new float[] { 50f, 50f, 150f }); // Y coordinates
Creates a closed polygon from two parallel coordinate arrays — all segments are straight lines (corner nodes only). The shape is automatically closed by connecting the last point back to the first.
| Parameter | Type | Description |
|---|---|---|
xs |
float[] |
X coordinates of all vertices (minimum 2) |
ys |
float[] |
Y coordinates of all vertices (minimum 2) |
Equivalent to BuildFreeform + AddNodes + ConvertToShape with msoSegmentLine segments, plus an automatic closing node. Use BuildFreeform directly for shapes with curves.
Generated automatically
The ⬇ Code button generates AddPolygon(...) automatically when a selected FreeForm shape has only straight-line segments (no curves).
AddPolyline(xs, ys)
dynamic oLine = ppptools.AddPolyline(
new float[] { 50f, 200f, 350f }, // X coordinates
new float[] { 100f, 200f, 100f }); // Y coordinates
Creates an open path — like AddPolygon but without the closing segment. Useful for lines, arrows, or open outlines.
| Parameter | Type | Description |
|---|---|---|
xs |
float[] |
X coordinates of all vertices (minimum 2) |
ys |
float[] |
Y coordinates of all vertices (minimum 2) |
AddTextBox(x, y, w, h)
dynamic oBox = ppptools.AddTextBox(100f, 80f, 300f, 50f);
ppptools.SetText(oBox, "Label", fontSize: 14f);
Adds a horizontal text box with no fill and no border. Unlike AddRect, a text box has no background by default.
| Parameter | Type | Default | Description |
|---|---|---|---|
x |
float |
— | Left position in points |
y |
float |
— | Top position in points |
w |
float |
— | Width in points |
h |
float |
36f |
Height in points (optional, default 36pt) |
AddLine(x1, y1, x2, y2)
// Horizontal divider line
dynamic oLine = ppptools.AddLine(50f, 200f, 670f, 200f);
ppptools.SetLine(oLine, Color.FromArgb(180, 180, 180), 1f);
// Diagonal line
dynamic oDiag = ppptools.AddLine(100f, 100f, 400f, 300f);
Adds a straight line between two points. For multi-segment lines → AddPolyline.
| Parameter | Type | Description |
|---|---|---|
x1, y1 |
float |
Start point |
x2, y2 |
float |
End point |
AddConnector(x1, y1, x2, y2, type)
// Simple curved connector (default)
dynamic oConn = ppptools.AddConnector(150f, 100f, 400f, 250f);
// Elbow connector (type 3)
dynamic oElbow = ppptools.AddConnector(150f, 100f, 400f, 250f, type: 3);
Adds a connector arrow. Unlike AddLine, a connector can be attached to shape connection points.
| Parameter | Type | Default | Description |
|---|---|---|---|
x1, y1 |
float |
— | Start point |
x2, y2 |
float |
— | End point |
type |
int |
2 |
Connector type: 1=Straight, 2=Curved, 3=Elbow, 4=Double-Elbow |
Selection
GetSelected(index = 1)
ppptools.Union();
dynamic oResult = ppptools.GetSelected(); // first shape in selection
dynamic oSecond = ppptools.GetSelected(2); // second shape (rarely needed)
Returns the shape at position index (1-based) in the current selection.
Typically used after Boolean operations to retrieve the result shape.
GetSelectedRange()
foreach (dynamic sh in ppptools.GetSelectedRange())
{
sh.Name = "MyShape";
}
Returns the full ShapeRange object of the current selection.
Boolean operations
All four operations work on the current selection. Select shapes first:
oA.Select(MsoTriState.msoTrue); // first shape (Replace = true → start new selection)
oB.Select(MsoTriState.msoFalse); // next shape (Replace = false → add to selection)
ppptools.Union();
dynamic oResult = ppptools.GetSelected();
The original shapes no longer exist after the operation — only the result remains.
Union()
Merges all selected shapes into one. The outer area of all shapes forms the new shape.
oStar.Select(MsoTriState.msoTrue);
oCircle.Select(MsoTriState.msoFalse);
ppptools.Union();
dynamic oUnion = ppptools.GetSelected();
Intersect()
Keeps only the area present in all selected shapes.
oLargeShape.Select(MsoTriState.msoTrue);
oClip.Select(MsoTriState.msoFalse);
ppptools.Intersect();
dynamic oClipped = ppptools.GetSelected();
Combine()
Combines shapes into one path — overlapping areas are punched out (hole).
oOuter.Select(MsoTriState.msoTrue);
oHole.Select(MsoTriState.msoFalse);
ppptools.Combine();
Subtract()
Subtracts the second shape from the first. The overlapping area is removed from the first shape.
oBase.Select(MsoTriState.msoTrue);
oCut.Select(MsoTriState.msoFalse);
ppptools.Subtract();
dynamic oResult = ppptools.GetSelected();
Grouping
GroupSelected()
oA.Select(MsoTriState.msoTrue);
oB.Select(MsoTriState.msoFalse);
dynamic oGroup = ppptools.GroupSelected();
Groups the current selection. Returns the group.
Group(shape1, shape2, ...)
dynamic oGroup = ppptools.Group(oBody, oHead, oText);
oGroup.Name = "Persona";
Selects all given shapes and groups them in a single call. Shorthand for manual Select + GroupSelected(). Returns the group.
Duplicate
Duplicate(shape)
dynamic oCopy = ppptools.Duplicate(oOriginal);
oCopy.Left = (float)oOriginal.Left + 50f;
Duplicates a shape and returns the new shape directly (not the duplicate range like PowerPoint's .Duplicate()). The copy appears slightly offset (PowerPoint default).
Z-Order
ppptools.SendBackward(oShape); // one layer back
ppptools.BringForward(oShape); // one layer forward
ppptools.SendToBack(oShape); // all the way back
ppptools.BringToFront(oShape); // all the way forward
Example — push shadow behind main shape:
var oShadow = ppptools.Duplicate(oMain);
// ... format shadow ...
ppptools.SendBackward(oShadow);
Flip
ppptools.FlipH(oShape); // flip horizontally
ppptools.FlipV(oShape); // flip vertically
Position & Size
CenterOnSlide(shape)
ppptools.CenterOnSlide(oGroup);
Centers a shape horizontally and vertically on the slide. Equivalent to:
oShape.Left = (ppptools.SlideWidth - (float)oShape.Width) / 2f;
oShape.Top = (ppptools.SlideHeight - (float)oShape.Height) / 2f;
Scale(shape, factor)
ppptools.Scale(oGroup, 1.5f); // enlarge to 150 %
ppptools.Scale(oGroup, 0.5f); // shrink to 50 %
Scales width and height proportionally by the given factor.
Styling
SetFill(shape, color, transparency = 0f)
ppptools.SetFill(oShape, Color.FromArgb(68, 114, 196)); // opaque
ppptools.SetFill(oShape, Color.FromArgb(68, 114, 196), 0.3f); // 30 % transparent
| Parameter | Type | Default | Description |
|---|---|---|---|
color |
Color |
— | Fill color |
transparency |
float |
0f |
0.0 = opaque, 1.0 = fully transparent |
SetGradient(shape, color1, color2, angle, pos1, pos2)
// Default: vertical gradient (90°), dark → light
ppptools.SetGradient(oShadow,
Color.FromArgb(38, 38, 38), // color1 — start color
Color.FromArgb(241, 241, 241)); // color2 — end color
// Custom angle
ppptools.SetGradient(oShape,
Color.FromArgb(70, 130, 180),
Color.FromArgb(135, 206, 235),
angle: 45f, pos1: 0.1f, pos2: 0.9f);
| Parameter | Type | Default | Description |
|---|---|---|---|
color1 |
Color |
— | Color at position pos1 |
color2 |
Color |
— | Color at position pos2 |
angle |
float |
90f |
0° = left→right, 90° = top→bottom |
pos1 |
float |
0.16f |
Position of color1 (0.0–1.0) |
pos2 |
float |
0.89f |
Position of color2 (0.0–1.0) |
SetLine(shape, color, weight, visible)
ppptools.SetLine(oShape, Color.FromArgb(90, 60, 180)); // default weight 1.5pt
ppptools.SetLine(oShape, Color.FromArgb(90, 60, 180), 2.5f); // weight 2.5pt
ppptools.SetLine(oShape, Color.Black, visible: false); // hide line
| Parameter | Type | Default | Description |
|---|---|---|---|
color |
Color |
— | Line color |
weight |
float |
1.5f |
Line weight in points |
visible |
bool |
true |
false → hide line (same as HideLine) |
HideLine(shape)
ppptools.HideLine(oShape);
Hides the outline (border) of a shape. Shorthand for SetLine(..., visible: false).
SetText(shape, text, fontName, fontSize, color, bold, align)
// Short form — text only
ppptools.SetText(oShape, "Hello World");
// With formatting
ppptools.SetText(oShape, "Title",
fontName: "Calibri",
fontSize: 16f,
color: Color.FromArgb(38, 38, 38),
bold: true,
align: PowerPoint.PpParagraphAlignment.ppAlignCenter);
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
string |
— | Text to display |
fontName |
string |
"Arial" |
Font name |
fontSize |
float |
12f |
Font size in points |
color |
Color? |
null |
Text color; null = unchanged |
bold |
bool |
false |
Bold |
align |
PpParagraphAlignment |
ppAlignLeft |
Text alignment |
Also sets: VerticalAnchor = msoAnchorMiddle, AutoSize = msoAutoSizeTextToFitShape.
Animations
AddAnimation(shape, effectId, triggerType = 1)
// Appear on click (default)
var anim = ppptools.AddAnimation(oShape, 1);
// Fade — triggered after previous animation ends
var anim = ppptools.AddAnimation(oShape, 2, 3);
// Fly — with custom timing
var anim = ppptools.AddAnimation(oShape, 3, 1);
anim.Timing.Duration = 0.5f;
anim.Timing.Delay = 0.2f;
Adds an entrance animation effect to a shape. Returns the Effect object for further timing configuration.
| Parameter | Type | Default | Description |
|---|---|---|---|
shape |
dynamic |
— | The shape to animate |
effectId |
int |
— | Effect type (see table below) |
triggerType |
int |
1 |
Trigger mode (see table below) |
Effect IDs (effectId):
| Value | Effect | Notes |
|---|---|---|
1 |
Appear | Instant, no duration |
2 |
Fade | Smooth fade-in |
3 |
Fly In | Slides in from outside |
Trigger types (triggerType):
| Value | Constant | Description |
|---|---|---|
1 |
OnClick | Starts on mouse click |
2 |
WithPrevious | Starts together with the previous effect |
3 |
AfterPrevious | Starts after the previous effect finishes |
Timing properties on the returned Effect:
var anim = ppptools.AddAnimation(oShape, 2, 1);
anim.Timing.Duration = 1.0f; // effect length in seconds
anim.Timing.Delay = 0.5f; // delay before start (seconds)
Generated automatically
The ⬇ Code button generates ppptools.AddAnimation(...) calls for any shapes that already have animations. The effectId and timing values are read from the existing animation and written as comments in the output.
Examples
| Example | Demonstrates |
|---|---|
| Gear Wheel | AddShape, AddOval, GetSelected, Boolean ops, SlideWidth/Height |
| Post-it | BuildFreeform, AddPolygon, Duplicate, FlipH, SendBackward, SetGradient, Group |
| Persona | BuildFreeform, AddOval, AddRect, Group, Scale, CenterOnSlide |
Back: Advanced Snippet Editor