PowerpointAutomation/de: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: PowerpointAutomation/de
| Old | New | Line | |
|---|---|---|---|
| 1 | + | \ | |
| 2 | + | Zurück zur [[Office Automation/de|Office Automation]].\ | |
| 3 | + | \ | |
| 4 | + | \ | |
| 5 | + | =Powerpoint als OleObjekt= Für die Oleautomation muss die Unit **ComObj** eingebunden werden.\ | |
| 6 | + | Grundsätzlich sollte für das Arbeiten mit Powerpoint die Unit **lclproc** eingebunden werden.\ | |
| 7 | + | Die Unit **lclproc** stellt die nötigen Routinen für das Umwandeln der Stringtypen (Stringcasting) bereit.\ | |
| 8 | + | \ | |
| 9 | + | ==Speicherplatz reservieren== | |
| 10 | + | ||
| 11 | + | ``` pascal | |
| 12 | + | var | |
| 13 | + | varPptApp: OleVariant; // reserviert den Speicher für die Powerpointadresse | |
| 14 | + | ``` | |
| 15 | + | ||
| 16 | + | \ | |
| 17 | + | ==OleObjekt erstellen== | |
| 18 | + | ||
| 19 | + | ``` pascal | |
| 20 | + | begin | |
| 21 | + | ... | |
| 22 | + | try | |
| 23 | + | varPptApp := CreateOleObject('Powerpoint.Application'); // erstellt das Powerpointobjekt | |
| 24 | + | except | |
| 25 | + | WriteLn('MS Powerpoint kann nicht gestartet werden.'); // Fehlerbehandlung | |
| 26 | + | end; | |
| 27 | + | ... | |
| 28 | + | end; | |
| 29 | + | ``` | |
| 30 | + | ||
| 31 | + | \ | |
| 32 | + | ==OleObjekt beenden und den Speicher freigeben== | |
| 33 | + | ||
| 34 | + | ``` pascal | |
| 35 | + | begin | |
| 36 | + | ... | |
| 37 | + | varPptApp.Quit; | |
| 38 | + | varPptApp := Unassigned; | |
| 39 | + | ... | |
| 40 | + | end; | |
| 41 | + | ``` | |
| 42 | + | ||
| 43 | + | \ | |
| 44 | + | ==Powerpoint Version ermitteln== | |
| 45 | + | ||
| 46 | + | ``` pascal | |
| 47 | + | begin | |
| 48 | + | ... | |
| 49 | + | ShowMessage(varPptApp.Version); | |
| 50 | + | ... | |
| 51 | + | end; | |
| 52 | + | ``` | |
| 53 | + | ||
| 54 | + | \ | |
| 55 | + | ==Sichtbarkeit steuern== Wenn Powerpoint während der automatisierten Erstellung einer Präsentation unsichtbar ist, dann flackert der Bildschirm nicht.\ | |
| 56 | + | ||
| 57 | + | ``` pascal | |
| 58 | + | begin | |
| 59 | + | ... | |
| 60 | + | varPptApp.Visible := False; //macht Powerpoint unsichtbar | |
| 61 | + | varPptApp.Visible := True; //macht Powerpoint sichtbar | |
| 62 | + | ... | |
| 63 | + | end; | |
| 64 | + | ``` | |
| 65 | + | ||
| 66 | + | \ | |
| 67 | + | =Powerpoint Präsentation=\ | |
| 68 | + | ==Speicher für die Präsentation reservieren== | |
| 69 | + | ||
| 70 | + | ``` pascal | |
| 71 | + | varPptSlide: OleVariant; // reserviert den Speicher für die Präsentation | |
| 72 | + | strName: String; | |
| 73 | + | ``` | |
| 74 | + | ||
| 75 | + | \ | |
| 76 | + | ==neue Datei erstellen== | |
| 77 | + | ||
| 78 | + | ``` pascal | |
| 79 | + | begin | |
| 80 | + | ... | |
| 81 | + | varPptApp.Presentations.Add(True); // Fügt eine neue Präsentation ein | |
| 82 | + | ... | |
| 83 | + | end; | |
| 84 | + | ``` | |
| 85 | + | ||
| 86 | + | \ | |
| 87 | + | ==vorhandene Datei öffnen== Um in Powerpoint eine vorhandene Präsentation zu öffnen, müssen sie den String in das UTF16-format umwandeln (casten),\ | |
| 88 | + | da die Powerpointschnittstelle nur UTF16 versteht.\ | |
| 89 | + | ||
| 90 | + | ``` pascal | |
| 91 | + | begin | |
| 92 | + | ... | |
| 93 | + | varPptApp.Presentations.Open(UTF8ToUTF16('D:\Arbeit\Test\TestDateien\Test.ppt')) // Benötigt die Unit lclproc | |
| 94 | + | ||
| 95 | + | // Alternative | |
| 96 | + | // Einer Variablen vom Typ OleVariant wird die Adresse der Prässentation übergeben | |
| 97 | + | varPptSlide := varPptApp.Presentations.Open(UTF8ToUTF16('D:\Arbeit\Test\TestDateien\Test.ppt')); | |
| 98 | + | ... | |
| 99 | + | end; | |
| 100 | + | ``` | |
| 101 | + | ||
| 102 | + | \ | |
| 103 | + | ==Präsentation speichern== | |
| 104 | + | ||
| 105 | + | ``` pascal | |
| 106 | + | begin | |
| 107 | + | ... | |
| 108 | + | varPptApp.ActivePresentation.Save; // speichert die aktive Präsentation | |
| 109 | + | // Alternative | |
| 110 | + | varPptSlide.Save; // speichert die aktive Präsentation | |
| 111 | + | ... | |
| 112 | + | end; | |
| 113 | + | ``` | |
| 114 | + | ||
| 115 | + | \ | |
| 116 | + | ==Präsentation steuern== | |
| 117 | + | ||
| 118 | + | ``` pascal | |
| 119 | + | var | |
| 120 | + | strName: String; // reserviert den Speicher für die den Namen der aktuellen Folie | |
| 121 | + | ``` | |
| 122 | + | ||
| 123 | + | \ | |
| 124 | + | ===Präsentation starten=== | |
| 125 | + | ||
| 126 | + | ``` pascal | |
| 127 | + | begin | |
| 128 | + | ... | |
| 129 | + | varPptApp.ActivePresentation.SlideShowSettings.Run; // führt die aktive Präsentation aus | |
| 130 | + | // Alternative | |
| 131 | + | varPptSlide.SlideShowSettings.Run; // führt die aktive Präsentation aus | |
| 132 | + | ... | |
| 133 | + | end; | |
| 134 | + | ``` | |
| 135 | + | ||
| 136 | + | \ | |
| 137 | + | ===Nächste Folie=== | |
| 138 | + | ||
| 139 | + | ``` pascal | |
| 140 | + | begin | |
| 141 | + | ... | |
| 142 | + | varPptApp.ActivePresentation.SlideShowWindow.View.Next; // führt die nächste Folie aus | |
| 143 | + | // Alternative | |
| 144 | + | varPptSlide.SlideShowWindow.View.Next; // führt die nächste Folie aus | |
| 145 | + | ... | |
| 146 | + | end; | |
| 147 | + | ``` | |
| 148 | + | ||
| 149 | + | \ | |
| 150 | + | ===vorhergehende Folie=== | |
| 151 | + | ||
| 152 | + | ``` pascal | |
| 153 | + | begin | |
| 154 | + | ... | |
| 155 | + | varPptApp.ActivePresentation.SlideShowWindow.View.Previous; // führt die vorhergehende Folie aus | |
| 156 | + | // Alternative | |
| 157 | + | varPptSlide.SlideShowWindow.View.Previous; // führt die vorhergehende Folie aus | |
| 158 | + | ... | |
| 159 | + | end; | |
| 160 | + | ``` | |
| 161 | + | ||
| 162 | + | \ | |
| 163 | + | ===geht zu Folie Nummer ...=== | |
| 164 | + | ||
| 165 | + | ``` pascal | |
| 166 | + | begin | |
| 167 | + | ... | |
| 168 | + | varPptApp.ActivePresentation.SlideShowWindow.View.GoToSlide(2); // führt die Folie Nummer 2 aus | |
| 169 | + | // Alternative | |
| 170 | + | varPptSlide.SlideShowWindow.View.GoToSlide(2); // führt die Folie Nummer 2 aus | |
| 171 | + | ... | |
| 172 | + | end; | |
| 173 | + | ``` | |
| 174 | + | ||
| 175 | + | \ | |
| 176 | + | ===geht zur letzten Folie=== | |
| 177 | + | ||
| 178 | + | ``` pascal | |
| 179 | + | begin | |
| 180 | + | ... | |
| 181 | + | varPptApp.ActivePresentation.SlideShowWindow.View.Last; // führt die letzte Folie aus | |
| 182 | + | // Alternative | |
| 183 | + | varPptSlide.SlideShowWindow.View.Last; // führt die letzte Folie aus | |
| 184 | + | ... | |
| 185 | + | end; | |
| 186 | + | ``` | |
| 187 | + | ||
| 188 | + | \ | |
| 189 | + | ===Name der aktuellen Folie ermitteln=== | |
| 190 | + | ||
| 191 | + | ``` pascal | |
| 192 | + | begin | |
| 193 | + | ... | |
| 194 | + | strName:= varPptApp.ActivePresentation.SlideShowWindow.View.Slide.Name; | |
| 195 | + | // Alternative | |
| 196 | + | strName:= varPptSlide.SlideShowWindow.View.Slide.Name; | |
| 197 | + | ... | |
| 198 | + | end; | |
| 199 | + | ``` | |
| 200 | + | ||
| 201 | + | # Folien | |
| 202 | + | ||
| 203 | + | ## Speicher reservieren | |
| 204 | + | ||
| 205 | + | ``` pascal | |
| 206 | + | var | |
| 207 | + | intZaehl: Integer; // reserviert den Speicher für die Anzahl der Folien | |
| 208 | + | ``` | |
| 209 | + | ||
| 210 | + | \ | |
| 211 | + | ==Folien zählen== | |
| 212 | + | ||
| 213 | + | ``` pascal | |
| 214 | + | begin | |
| 215 | + | ... | |
| 216 | + | intZaehl := varPptApp.ActivePresentation.Slides.Count; //Zählt die Folien | |
| 217 | + | // Alternative | |
| 218 | + | intZaehl := varPptSlide.Slides.Count; //Zählt die Folien | |
| 219 | + | ... | |
| 220 | + | end; | |
| 221 | + | ``` | |
| 222 | + | ||
| 223 | + | \ | |
| 224 | + | =Auszug aus den Powerpointkonstanten= | |
| 225 | + | ||
| 226 | + | ``` pascal | |
| 227 | + | unit uPPTConst; | |
| 228 | + | ||
| 229 | + | interface | |
| 230 | + | ||
| 231 | + | const | |
| 232 | + | ppSaveAsPresentation = $00000001; | |
| 233 | + | ppSaveAsPowerPoint7 = $00000002; | |
| 234 | + | ppSaveAsPowerPoint4 = $00000003; | |
| 235 | + | ppSaveAsPowerPoint3 = $00000004; | |
| 236 | + | ppSaveAsTemplate = $00000005; | |
| 237 | + | ppSaveAsRTF = $00000006; | |
| 238 | + | ppSaveAsShow = $00000007; | |
| 239 | + | ppSaveAsAddIn = $00000008; | |
| 240 | + | ppSaveAsWizard = $00000009; | |
| 241 | + | ppSaveAsPowerPoint4FarEast = $0000000A; | |
| 242 | + | ppSaveAsDefault = $0000000B; | |
| 243 | + | ||
| 244 | + | //Bibliothek PpSlideLayout | |
| 245 | + | ppLayoutBlank = 12; | |
| 246 | + | ppLayoutChart = 8; | |
| 247 | + | ppLayoutChartAndText = 6; | |
| 248 | + | ppLayoutClipartAndText = 10; | |
| 249 | + | ppLayoutClipArtAndVerticalText = 26; | |
| 250 | + | ppLayoutFourObjects = 24; | |
| 251 | + | ppLayoutLargeObject = 15; | |
| 252 | + | ppLayoutMediaClipAndText = 18; | |
| 253 | + | ppLayoutMixed = -2; | |
| 254 | + | ppLayoutObject = 16; | |
| 255 | + | ppLayoutObjectAndText = 14; | |
| 256 | + | ppLayoutObjectAndTwoObjects = 30; | |
| 257 | + | ppLayoutObjectOverText = 19; | |
| 258 | + | ppLayoutOrgchart = 7; | |
| 259 | + | ppLayoutTable = 4; | |
| 260 | + | ppLayoutText = 2; | |
| 261 | + | ppLayoutTextAndChart = 5; | |
| 262 | + | ppLayoutTextAndClipart = 9; | |
| 263 | + | ppLayoutTextAndMediaClip = 17; | |
| 264 | + | ppLayoutTextAndObject = 13; | |
| 265 | + | ppLayoutTextAndTwoObjects = 21; | |
| 266 | + | ppLayoutTextOverObject = 20; | |
| 267 | + | ppLayoutTitle = 1; | |
| 268 | + | ppLayoutTitleOnly = 11; | |
| 269 | + | ppLayoutTwoColumnText = 3; | |
| 270 | + | ppLayoutTwoObjects = 29; | |
| 271 | + | ppLayoutTwoObjectsAndObject = 31; | |
| 272 | + | ppLayoutTwoObjectsAndText = 22; | |
| 273 | + | ppLayoutTwoObjectsOverText = 23; | |
| 274 | + | ppLayoutVerticalText = 25; | |
| 275 | + | ppLayoutVerticalTitleAndText = 27; | |
| 276 | + | ppLayoutVerticalTitleAndTextOverChart = 28; | |
| 277 | + | ||
| 278 | + | // Bibliothek MsoTriState | |
| 279 | + | msoCTrue = 1; | |
| 280 | + | msoFalse = 0; | |
| 281 | + | msoTriStateMixed = -2; | |
| 282 | + | msoTriStateToggle = -3; | |
| 283 | + | msoTrue = -1; | |
| 284 | + | ||
| 285 | + | implementation | |
| 286 | + | ||
| 287 | + | end. | |
| 288 | + | ``` | |
| 289 | + | ||
| 290 | + | --- | |
| 291 | + | *From the Free Pascal wiki, page "PowerpointAutomation/de", as it stood on 2020-02-23 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
