PPPTools-Referenz (AdvancedScriptHelper)

Erstellt: 2026-05-29 · Aktualisiert: 2026-05-31

Advanced Snippet Editor

ppptools ist die einzige Variable im Script, die Zugriff auf PowerPoint gibt. Alle Methoden sind auf der Instanz aufrufbar — kein new, kein direkter COM-Zugriff nötig.


Folie

SlideWidth / SlideHeight

float w = ppptools.SlideWidth;   // z.B. 720f (Punkte)
float h = ppptools.SlideHeight;  // z.B. 540f (Punkte)

Breite und Höhe der aktiven Folie in Punkten (1 Punkt = 1/72 Zoll). Zum Zentrieren:

float left = (ppptools.SlideWidth  - shapeWidth)  / 2f;
float top  = (ppptools.SlideHeight - shapeHeight) / 2f;

Shapes erstellen

AddShape(type, x, y, w, h)

dynamic oShape = ppptools.AddShape(MsoAutoShapeType.msoShape8pointStar, 100f, 80f, 200f, 200f);

Fügt eine AutoShape auf der aktiven Folie ein. Alle verfügbaren Typen mit Beispielen: → AutoShape-Typen (MsoAutoShapeType)

Vollständige Microsoft-Referenz: MsoAutoShapeType auf learn.microsoft.com

Parameter Typ Beschreibung
type MsoAutoShapeType Form-Typ
x float Linke Position in Punkten
y float Obere Position in Punkten
w float Breite in Punkten
h float Höhe in Punkten

AddRect(x, y, w, h)

dynamic oRect = ppptools.AddRect(50f, 50f, 200f, 150f);

Kurzform für AddShape(msoShapeRectangle, ...).


AddOval(x, y, w, h)

dynamic oCircle = ppptools.AddOval(100f, 100f, 80f, 80f);  // Kreis 80×80

Kurzform für AddShape(msoShapeOval, ...). Für einen exakten Kreis: 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();

Startet einen Freeform-Builder. Der Rückgabewert ist ein FreeformBuilder-Objekt mit den Methoden .AddNodes(...) und .ConvertToShape().

Parameter Typ Beschreibung
editingType MsoEditingType msoEditingCorner (scharfe Ecken) oder msoEditingAuto (Kurven)
x, y float Startpunkt des ersten Nodes

AddPolygon(xs, ys)

dynamic oShape = ppptools.AddPolygon(
    new float[] { 100f, 200f, 150f },   // X-Koordinaten
    new float[] {  50f,  50f, 150f });  // Y-Koordinaten

Erstellt ein geschlossenes Polygon aus zwei parallelen Koordinaten-Arrays — alle Segmente sind gerade Linien (Corner-Nodes). Die Form wird automatisch geschlossen (letzter Punkt → erster Punkt).

Parameter Typ Beschreibung
xs float[] X-Koordinaten aller Eckpunkte (mindestens 2)
ys float[] Y-Koordinaten aller Eckpunkte (mindestens 2)

Entspricht BuildFreeform + AddNodes + ConvertToShape mit msoSegmentLine-Segmenten. Für Kurven: direkt BuildFreeform verwenden.

Automatisch generiert

Der ⬇ Code-Button erzeugt AddPolygon(...) automatisch, wenn ein selektiertes FreeForm-Shape nur gerade Segmente (keine Kurven) hat.


AddPolyline(xs, ys)

dynamic oLine = ppptools.AddPolyline(
    new float[] { 50f, 200f, 350f },    // X-Koordinaten
    new float[] { 100f, 200f, 100f });  // Y-Koordinaten

Erstellt einen offenen Pfad — wie AddPolygon, aber ohne das abschliessende Segment. Nützlich für Linien, Pfeile oder offene Umrisse.

Parameter Typ Beschreibung
xs float[] X-Koordinaten aller Punkte (mindestens 2)
ys float[] Y-Koordinaten aller Punkte (mindestens 2)

AddTextBox(x, y, w, h)

dynamic oBox = ppptools.AddTextBox(100f, 80f, 300f, 50f);
ppptools.SetText(oBox, "Beschriftung", fontSize: 14f);

Fügt eine horizontale Textbox ohne Füllfarbe und ohne Rahmen ein. Im Gegensatz zu AddRect hat eine Textbox standardmässig keinen Hintergrund.

Parameter Typ Standard Beschreibung
x float Linke Position in Punkten
y float Obere Position in Punkten
w float Breite in Punkten
h float 36f Höhe in Punkten (optional, Standard 36pt)

AddLine(x1, y1, x2, y2)

// Horizontale Trennlinie
dynamic oLine = ppptools.AddLine(50f, 200f, 670f, 200f);
ppptools.SetLine(oLine, Color.FromArgb(180, 180, 180), 1f);

// Diagonale Linie
dynamic oDiag = ppptools.AddLine(100f, 100f, 400f, 300f);

Fügt eine gerade Linie zwischen zwei Punkten ein. Für mehrsegmentige Linien → AddPolyline.

Parameter Typ Beschreibung
x1, y1 float Startpunkt
x2, y2 float Endpunkt

AddConnector(x1, y1, x2, y2, type)

// Einfacher gerader Verbindungspfeil (Standard)
dynamic oConn = ppptools.AddConnector(150f, 100f, 400f, 250f);

// Geknickter Verbindungspfeil (Elbow = Typ 3)
dynamic oElbow = ppptools.AddConnector(150f, 100f, 400f, 250f, type: 3);

Fügt einen Verbindungspfeil (Connector) ein. Im Gegensatz zu AddLine kann ein Connector an Shape-Verbindungspunkte angedockt werden.

Parameter Typ Standard Beschreibung
x1, y1 float Startpunkt
x2, y2 float Endpunkt
type int 2 Connector-Typ: 1=Straight, 2=Curved, 3=Elbow, 4=Double-Elbow

Selektion

GetSelected(index = 1)

ppptools.Union();
dynamic oResult = ppptools.GetSelected();     // erstes Shape in der Selektion
dynamic oSecond = ppptools.GetSelected(2);    // zweites Shape (selten benötigt)

Gibt das Shape an Position index (1-basiert) der aktuellen Selektion zurück. Wird typischerweise nach Boolean-Operationen eingesetzt, um das Ergebnis-Shape zu greifen.


GetSelectedRange()

foreach (dynamic sh in ppptools.GetSelectedRange())
{
    sh.Name = "MyShape";
}

Gibt das gesamte ShapeRange-Objekt der aktuellen Selektion zurück.


Boolean-Operationen

Alle vier Operationen arbeiten auf der aktuellen Selektion. Shapes vorher selektieren:

oA.Select(MsoTriState.msoTrue);   // erstes Shape (Replace = true → Selektion neu starten)
oB.Select(MsoTriState.msoFalse);  // weiteres Shape (Replace = false → zur Selektion hinzufügen)
ppptools.Union();
dynamic oResult = ppptools.GetSelected();

Die beteiligten Original-Shapes existieren nach der Operation nicht mehr — nur das Ergebnis bleibt.

Union()

Vereinigt alle selektierten Shapes zu einem. Die Aussenfläche aller Formen ergibt die neue Form.

oStar.Select(MsoTriState.msoTrue);
oCircle.Select(MsoTriState.msoFalse);
ppptools.Union();
dynamic oUnion = ppptools.GetSelected();

Intersect()

Behält nur den Bereich, der in allen selektierten Shapes liegt.

oLargeShape.Select(MsoTriState.msoTrue);
oClip.Select(MsoTriState.msoFalse);
ppptools.Intersect();
dynamic oClipped = ppptools.GetSelected();

Combine()

Kombiniert Shapes zu einem Pfad — Überschneidungsbereiche werden ausgestanzt (Loch).

oOuter.Select(MsoTriState.msoTrue);
oHole.Select(MsoTriState.msoFalse);
ppptools.Combine();

Subtract()

Subtrahiert das zweite Shape vom ersten. Überlappender Bereich wird aus dem ersten entfernt.

oBase.Select(MsoTriState.msoTrue);
oCut.Select(MsoTriState.msoFalse);
ppptools.Subtract();
dynamic oResult = ppptools.GetSelected();

Gruppieren

GroupSelected()

oA.Select(MsoTriState.msoTrue);
oB.Select(MsoTriState.msoFalse);
dynamic oGroup = ppptools.GroupSelected();

Gruppiert die aktuelle Selektion. Gibt die Gruppe zurück.

Group(shape1, shape2, ...)

dynamic oGroup = ppptools.Group(oBody, oHead, oText);
oGroup.Name = "Persona";

Selektiert alle übergebenen Shapes und gruppiert sie in einem Aufruf. Kurzform für manuelles Select + GroupSelected(). Gibt die Gruppe zurück.


Duplizieren

Duplicate(shape)

dynamic oCopy = ppptools.Duplicate(oOriginal);
oCopy.Left = (float)oOriginal.Left + 50f;

Dupliziert ein Shape und gibt das neue Shape direkt zurück (nicht den Duplicate-Range wie PowerPoint's .Duplicate()). Das Duplikat erscheint minimal versetzt (PowerPoint-Standard).


Z-Order

ppptools.SendBackward(oShape);   // eine Ebene nach hinten
ppptools.BringForward(oShape);   // eine Ebene nach vorne
ppptools.SendToBack(oShape);     // ganz nach hinten
ppptools.BringToFront(oShape);   // ganz nach vorne

Beispiel: Schatten hinter das Hauptobjekt schieben:

var oShadow = ppptools.Duplicate(oMain);
// ... Schatten formatieren ...
ppptools.SendBackward(oShadow);

Spiegeln

ppptools.FlipH(oShape);  // horizontal spiegeln
ppptools.FlipV(oShape);  // vertikal spiegeln

Position & Grösse

CenterOnSlide(shape)

ppptools.CenterOnSlide(oGroup);

Zentriert ein Shape horizontal und vertikal auf der Folie. Äquivalent zu:

oShape.Left = (ppptools.SlideWidth  - (float)oShape.Width)  / 2f;
oShape.Top  = (ppptools.SlideHeight - (float)oShape.Height) / 2f;

Scale(shape, factor)

ppptools.Scale(oGroup, 1.5f);   // auf 150 % vergrössern
ppptools.Scale(oGroup, 0.5f);   // auf 50 % verkleinern

Skaliert Breite und Höhe proportional um den angegebenen Faktor.


Styling

SetFill(shape, color, transparency = 0f)

ppptools.SetFill(oShape, Color.FromArgb(68, 114, 196));           // opake Farbe
ppptools.SetFill(oShape, Color.FromArgb(68, 114, 196), 0.3f);    // 30 % transparent
Parameter Typ Standard Beschreibung
color Color Füllfarbe
transparency float 0f 0.0 = opak, 1.0 = vollständig transparent

SetGradient(shape, color1, color2, angle, pos1, pos2)

// Standard: vertikaler Verlauf (90°), dunkel→hell
ppptools.SetGradient(oShadow,
    Color.FromArgb(38,  38,  38),   // color1 — Startfarbe
    Color.FromArgb(241, 241, 241)); // color2 — Endfarbe

// Eigener Winkel
ppptools.SetGradient(oShape,
    Color.FromArgb(70, 130, 180),
    Color.FromArgb(135, 206, 235),
    angle: 45f, pos1: 0.1f, pos2: 0.9f);
Parameter Typ Standard Beschreibung
color1 Color Farbe an Position pos1
color2 Color Farbe an Position pos2
angle float 90f 0° = links→rechts, 90° = oben→unten
pos1 float 0.16f Position von color1 (0.0–1.0)
pos2 float 0.89f Position von color2 (0.0–1.0)

SetLine(shape, color, weight, visible)

ppptools.SetLine(oShape, Color.FromArgb(90, 60, 180));          // Standardstärke 1.5pt
ppptools.SetLine(oShape, Color.FromArgb(90, 60, 180), 2.5f);    // Stärke 2.5pt
ppptools.SetLine(oShape, Color.Black, visible: false);           // Linie verstecken
Parameter Typ Standard Beschreibung
color Color Linienfarbe
weight float 1.5f Linienstärke in Punkten
visible bool true false → Linie wird versteckt (wie HideLine)

HideLine(shape)

ppptools.HideLine(oShape);

Versteckt die Konturlinie (Rahmen) eines Shapes. Kurzform für SetLine(..., visible: false).


SetText(shape, text, fontName, fontSize, color, bold, align)

// Kurzform — nur Text
ppptools.SetText(oShape, "Hallo Welt");

// Mit Formatierung
ppptools.SetText(oShape, "Titel",
    fontName: "Calibri",
    fontSize: 16f,
    color: Color.FromArgb(38, 38, 38),
    bold: true,
    align: PowerPoint.PpParagraphAlignment.ppAlignCenter);
Parameter Typ Standard Beschreibung
text string Anzuzeigender Text
fontName string "Arial" Schriftart
fontSize float 12f Schriftgrösse in Punkten
color Color? null Textfarbe; null = unverändert
bold bool false Fettschrift
align PpParagraphAlignment ppAlignLeft Textausrichtung

Setzt ausserdem: VerticalAnchor = msoAnchorMiddle, AutoSize = msoAutoSizeTextToFitShape.


Tipp: Folie zentrieren mit allen Methoden

// Variante 1 — CenterOnSlide
ppptools.CenterOnSlide(oGroup);

// Variante 2 — manuell (wenn vorher skaliert wurde)
oGroup.Left = (ppptools.SlideWidth  - (float)oGroup.Width)  / 2f;
oGroup.Top  = (ppptools.SlideHeight - (float)oGroup.Height) / 2f;

Beispiele

Beispiel Zeigt
Zahnrad AddShape, AddOval, GetSelected, Boolean-Ops, SlideWidth/Height
PostIt BuildFreeform, Duplicate, FlipH, SendBackward, SetGradient, Group
Persona BuildFreeform, AddOval, AddRect, Group, Scale, CenterOnSlide

Zurück: Advanced Snippet Editor