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