PowerpointAutomation/de

From Lazarus wiki
Jump to navigationJump to search

Deutsch (de)


Powerpoint als OleObjekt

Für die Oleautomation muss die Unit ComObj eingebunden werden.

Speicherplatz reservieren

var
  varPptApp: OleVariant;


Powerpoint: OleObjekt erstellen

begin
  ...
  try
    varPptApp := CreateOleObject('Powerpoint.Application'); // erstellt das Powerpointobjekt
  except
    WriteLn('MS Powerpoint kann nicht gestartet werden.'); // Fehlerbehandlung
  end;
  ...
end;


Powerpoint: OleObjekt beenden und den Speicher freigeben

begin
  ...
  varPptApp.Quit;
  varPptApp := Unassigned;
  ...
end;


Powerpoint: Version ermitteln

begin
  ...
  ShowMessage(varPptApp.Version);
  ...
end;


Powerpoint: neue Datei erstellen

begin
  ...
  varPptApp.Presentations.Add(True);  // Fügt eine neue Präsentation ein
  ...
end;


Powerpoint: vorhandene Datei öffnen

Um in Powerpoint eine vorhandene Präsentation zu öffnen, müssen sie den String in das UTF16-format umwandeln (casten),
da die Powerpointschnittstelle nur UTF16 versteht.

begin
  ...
  varPptApp.Presentations.Open(UTF8ToUTF16('D:\Arbeit\Test\TestDateien\Test.ppt')) // Benötigt die Unit lclproc 
  ...
end;


Powerpoint: Sichtbarkeit steuern

Wenn Powerpoint während der Erstellung einer Präsentation unsichtbar ist, dann flackert der Bildschirm nicht.

begin
  ...
  varPptApp.Visible := False;  //macht Powerpoint unsichtbar
  varPptApp.Visible := True;   //macht Powerpoint sichtbar
  ...
end;

Auszug aus den Powerpointkonstanten

unit uPPTConst;

interface

const
  ppSaveAsPresentation = $00000001;
  ppSaveAsPowerPoint7 = $00000002;
  ppSaveAsPowerPoint4 = $00000003;
  ppSaveAsPowerPoint3 = $00000004;
  ppSaveAsTemplate = $00000005;
  ppSaveAsRTF = $00000006;
  ppSaveAsShow = $00000007;
  ppSaveAsAddIn = $00000008;
  ppSaveAsWizard = $00000009;
  ppSaveAsPowerPoint4FarEast = $0000000A;
  ppSaveAsDefault = $0000000B;

//Bibliothek PpSlideLayout
  ppLayoutBlank = 12;
  ppLayoutChart = 8;
  ppLayoutChartAndText = 6;
  ppLayoutClipartAndText = 10;
  ppLayoutClipArtAndVerticalText = 26;
  ppLayoutFourObjects = 24;
  ppLayoutLargeObject = 15;
  ppLayoutMediaClipAndText = 18;
  ppLayoutMixed = -2;
  ppLayoutObject = 16;
  ppLayoutObjectAndText = 14;
  ppLayoutObjectAndTwoObjects = 30;
  ppLayoutObjectOverText = 19;
  ppLayoutOrgchart = 7;
  ppLayoutTable = 4;
  ppLayoutText = 2;
  ppLayoutTextAndChart = 5;
  ppLayoutTextAndClipart = 9;
  ppLayoutTextAndMediaClip = 17;
  ppLayoutTextAndObject = 13;
  ppLayoutTextAndTwoObjects = 21;
  ppLayoutTextOverObject = 20;
  ppLayoutTitle = 1;
  ppLayoutTitleOnly = 11;
  ppLayoutTwoColumnText = 3;
  ppLayoutTwoObjects = 29;
  ppLayoutTwoObjectsAndObject = 31;
  ppLayoutTwoObjectsAndText = 22;
  ppLayoutTwoObjectsOverText = 23;
  ppLayoutVerticalText = 25;
  ppLayoutVerticalTitleAndText = 27;
  ppLayoutVerticalTitleAndTextOverChart = 28;

  // Bibliothek MsoTriState
  msoCTrue = 1;
  msoFalse = 0;
  msoTriStateMixed = -2;
  msoTriStateToggle = -3;
  msoTrue = -1;

implementation

end.



--Olaf 18:48, 26 September 2012 (UTC)