-
Notifications
You must be signed in to change notification settings - Fork 1
/
Powerpoint.au3
527 lines (494 loc) · 15.4 KB
/
Powerpoint.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
#include-once
#comments-start
Functions - Create and Edit
----------------------
_PPT_PowerPointApp()
_PPT_PowerPointQuit()
_PPT_CreatePresentation()
_PPT_PresentationAdd()
_PPT_PresentationOpen()
_PPT_PresentationSaved()
_PPT_PresentationSaveAs()
_PPT_PresentationName()
_PPT_PresentationClose()
_PPT_SlideCreate()
_PPT_SlideTextFrameSetText()
_PPT_SlideTextFrameGetText()
_PPT_SlideTextFrameSetFont()
_PPT_SlideTextFrameSetFontSize()
_PPT_SlideCount()
_PPT_SlideShapeCount()
_PPT_SlideAddPicture()
_PPT_SlideAddTable()
_PPT_SlideAddTextBox()
Functions - Slide Show Config Settings
----------------------
_PPT_SlideShowStartingSlide()
_PPT_SlideShowEndingSlide()
_PPT_SlideShowWithAnimation()
_PPT_SlideShowWithNarration()
_PPT_SlideShowLoopUntilStopped()
_PPT_SlideShowAdvanceMode()
_PPT_SlideShowShowType()
_PPT_SlideShowRangeType()
_PPT_SlideShowRun()
_PPT_SlideShowAdvanceOnTime()
_PPT_SlideShowAdvanceTime()
Functions - Misc
----------------------
_PPT_bAssistant()
_PPT_SlideSelect()
#comments-end
#comments-start -------------------------------------------------
PowerPoint constants
#comments-end ---------------------------------------------------
; _PPT_SlideCreate() layout types
Global Const $PPLAYOUTTITLE = 1
Global Const $PPLAYOUTTEXT = 2
Global Const $PPLAYOUTBLANK = 12
Global Const $PPLAYOUTCHART = 8
Global Const $PPLAYOUTCHARTANDTEXT = 6
Global Const $PPLAYOUTCLIPARTANDTEXT = 10
Global Const $PPLAYOUTCLIPARTANDVERTICALTEXT = 26
Global Const $PPLAYOUTTITLEONLY = 11
; _PPT_SlideShowAdvanceMode() modes
Global Const $PPMANUALADVANCE = 1
Global Const $PPUSETIMINGS = 2
Global Const $PPREHEARSENEWTIMINGS = 3
; _PPT_SlideShowShowType() types
Global Const $PPSHOWSPEAKER = 1 ;Only use speaker
Global Const $PPRSHOWWINDOW = 2 ;Display window around slides
Global Const $PPSHOWKIOSK = 3 ;Display full screen
; _PPT_SlideShowRangeType() types
Global Const $PPRANGETYPESHOWALL = 1 ; Show all slides
Global Const $PPRANGETYPESHOWBYRANGE = 2 ;Show by using start and ending range
Global Const $PPRANGETYPESHOWNAMEDSLIDESHOW = 3 ;Show named slides
#comments-start -------------------------------------------------
PowerPoint function implimentations
#comments-end ---------------------------------------------------
;===============================================================================
;
; Function Name: _PPT_SlideTextFrameSetText()
; Description: Sets the text of a specified TextFrame in a slide
; Parameter(s): $obj - Slide object
; $intTextFrame - Index of TextFrame on slide
; $Text - String text
; Return Value(s): On Success - Slide's text frame text set
; On Failure - @error = 1, Returns 0
; Author(s): Toady (Josh Bolton)
;
;===============================================================================
Func _PPT_SlideTextFrameSetText(ByRef $obj, $intTextFrame, $Text)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.Shapes.Item($intTextFrame).TextFrame.TextRange.Text = $Text
Endif
EndFunc
;===============================================================================
;
; Function Name: _PPT_SlideTextFrameTextSetFont()
; Description: Sets the font face
; Parameter(s): $obj - Slide object
; $intTextFrame - Index of TextFrame on slide
; $font - String text ex. "Comic Sans MS"
; Return Value(s): On Success - Slide's text frame text set
; On Failure - @error = 1, Returns 0
; Author(s): Toady (Josh Bolton)
;
;===============================================================================
Func _PPT_SlideTextFrameSetFont(ByRef $obj, $intTextFrame, $font)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
Local $objTextRng = $obj.Shapes.Item($intTextFrame).TextFrame.TextRange
$objTextRng.Font.Name = $font
Endif
EndFunc
;===============================================================================
;
; Function Name: _PPT_SlideTextFrameTextSetFontSize()
; Description: Sets the text size
; Parameter(s): $obj - Slide object
; $intTextFrame - Index of TextFrame on slide
; $size - Integer value (ex. 24 or 36)
; Return Value(s): On Success - Slide's text frame text set
; On Failure - @error = 1, Returns 0
; Author(s): Toady (Josh Bolton)
;
;===============================================================================
Func _PPT_SlideTextFrameSetFontSize(ByRef $obj, $intTextFrame, $size)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
Local $objTextRng = $obj.Shapes.Item($intTextFrame).TextFrame.TextRange
$objTextRng.Font.Size = $size
Endif
EndFunc
;===============================================================================
;
; Function Name: _PPT_SlideSelect()
; Description: Selects a slide within PowerPoint
; Parameter(s): $obj - Presentation object
; Return Value(s): On Success - Slide's text frame text set
; On Failure - @error = 1, Returns 0
; Author(s): Toady (Josh Bolton)
;
;===============================================================================
Func _PPT_SlideSelect(ByRef $obj)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.Select()
Endif
EndFunc
;===============================================================================
;
; Function Name: _PPT_SlideShowRun()
; Description: Runs the slide show for presentation, same as pressing F5 in PPT
; Parameter(s): $obj - Presentation object
; Return Value(s): On Success - Presentation is ran
; On Failure - @error = 1, Returns 0
; Author(s): Toady (Josh Bolton)
;
;===============================================================================
Func _PPT_SlideShowRun(ByRef $obj)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.SlideShowSettings.Run()
Endif
EndFunc
;===============================================================================
;
; Function Name: _PPT_SlideShowShowType()
; Description: Sets the type of slide show type for presentation
; Parameter(s): $obj - Presentation oject
; $intType - Either be 1, 2, or 3.. See constants above for types
; Return Value(s): On Success - Slide show type is modified
; On Failure - @error = 1, Returns 0
; - @error = 2, Returns 2, Invalid type mode
; Author(s): Toady (Josh Bolton)
;
;===============================================================================
Func _PPT_SlideShowShowType(ByRef $obj, $intType)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
ElseIf $intType > 3 Or $intType < 1 Then
SetError(2)
Return 2
Else
$obj.SlideShowSettings.ShowType = $intType
Endif
EndFunc
;===============================================================================
;
; Function Name: _PPT_SlideShowRangeType()
; Description: Sets the range of slides that get displayed during slide show
; Parameter(s): $obj - Presentation oject
; $intType - Either be 1, 2, or 3.. See constants above for types
; Return Value(s): On Success - Slide show ranges are modified
; On Failure - @error = 1, Returns 0
; - @error = 2, Returns 2, Invalid type mode
; Author(s): Toady (Josh Bolton)
;
;===============================================================================
Func _PPT_SlideShowRangeType(ByRef $obj, $intType)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
ElseIf $intType > 3 Or $intType < 1 Then
SetError(2)
Return 2
Else
$obj.SlideShowSettings.RangeType = $intType
Endif
EndFunc
;===============================================================================
;
; Function Name: _PPT_SlideShowAdvanceTime()
; Description: Sets the number of each seconds each slide gets displayed globally
; Parameter(s): $obj - Presentation oject
; $intType - Integer, number of seconds
; Return Value(s): On Success - Slide show advance times are modified
; On Failure - @error = 1, Returns 0
; - @error = 2, Returns 2, Invalid type second
; Author(s): Toady (Josh Bolton)
;
;===============================================================================
Func _PPT_SlideShowAdvanceTime(ByRef $obj, $intSecond)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
ElseIf IsInt($intSecond) = 0 Then
SetError(2)
Return 2
Else
$obj.Slides.Range.SlideShowTransition.AdvanceTime = $intSecond
Endif
EndFunc
;===============================================================================
;
; Function Name: _PPT_SlideShowAdvanceOnTime()
; Description: Tells PowerPoint to use global advance times
; Parameter(s): $obj - Presentation object
; $boolean - True or False
; Return Value(s): On Success - Slides use advance times
; On Failure - @error = 1, Returns 0
; Author(s): Toady (Josh Bolton)
;
;===============================================================================
Func _PPT_SlideShowAdvanceOnTime(ByRef $obj, $boolean)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.Slides.Range.SlideShowTransition.AdvanceOnTime = $boolean
Endif
EndFunc
;===============================================================================
;
; Function Name: _PPT_SlideShowLoopUntilStopped()
; Description: Tells PowerPoint to loop presentation until manually stopped
; Parameter(s): $obj - Presentation object
; $boolean - True or False
; Return Value(s): On Success - Loop slide show until stopped
; On Failure - @error = 1, Returns 0
; Author(s): Toady (Josh Bolton)
;
;===============================================================================
Func _PPT_SlideShowLoopUntilStopped(ByRef $obj, $boolean)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.SlideShowSettings.LoopUntilStopped = $boolean
Endif
EndFunc
;===============================================================================
;
; Function Name: _PPT_bAssistant()
; Description: Tells PowerPoint to turn on or off the Assistant
; Parameter(s): $obj - Presentation object
; $boolean - True or False
; Return Value(s): On Success - Loop slide show until stopped
; On Failure - @error = 1, Returns 0
; Author(s): Toady (Josh Bolton)
;
;===============================================================================
Func _PPT_bAssistant(ByRef $obj, $boolean)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.Assistant.On = $boolean
Endif
EndFunc
Func _PPT_SlideShowAdvanceMode(ByRef $obj, $intMode)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
ElseIf $intMode > 3 Or $intMode < 1 Then
SetError(2)
Return 2
Else
$obj.SlideShowSettings.ShowScrollbar = $intMode
Endif
EndFunc
Func _PPT_SlideShowDisplayScrollbars(ByRef $obj, $boolean)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.SlideShowSettings.ShowScrollbar = $boolean
Endif
EndFunc
Func _PPT_SlideShowWithNarration(ByRef $obj, $boolean)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.SlideShowSettings.ShowWithNarration = $boolean
Endif
EndFunc
Func _PPT_SlideShowWithAnimation(ByRef $obj, $boolean)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.SlideShowSettings.ShowWithAnimation = $boolean
Endif
EndFunc
Func _PPT_SlideShowStartingSlide(ByRef $obj, $intSlide)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.SlideShowSettings.StartingSlide = $intSlide
Endif
EndFunc
Func _PPT_SlideShowEndingSlide(ByRef $obj, $intSlide)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.SlideShowSettings.EndingSlide = $intSlide
Endif
EndFunc
Func _PPT_PresentationSaveAs(ByRef $obj, $filename)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.SaveAs($filename)
Endif
EndFunc
Func _PPT_PresentationClose(ByRef $obj)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.Close()
Endif
EndFunc
Func _PPT_PresentationName($obj)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
Return $obj.Name()
Endif
EndFunc
Func _PPT_PresentationSaved($obj)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
Return $obj.Saved
Endif
EndFunc
Func _PPT_SlideAddPicture(ByRef $obj, $filepath, $left = 0, $top = 0, $width = 100, $height = 100)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
ElseIf FileExists($filepath) <> 1 Then
SetError(2)
Return 2 ;file does not exist
ElseIf $left = "" Or $top = "" Or $width = "" Or $height = "" Then
SetError(3)
Return 3
ElseIf IsInt($left+$top+$width+$height) <> 1 Then
SetError(4)
Return 4 ;All parameters have to be integer
Else
$obj.Shapes.AddPicture($filepath, 0, 1,150, 150, 500, 350)
Endif
EndFunc
Func _PPT_SlideAddTable(ByRef $obj, $rows, $cols, $left = -1, $top = -1, $width = -1, $height = -1)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
ElseIf $left = "" Or $top = "" Or $width = "" Or $height = "" Then
SetError(3)
Return 3
ElseIf IsInt($left+$top+$width+$height) <> 1 Then
SetError(4)
Return 4 ;All parameters have to be integer
Else
$obj.Shapes.AddTable($rows, $cols, $left, $top, $width, $height)
Endif
EndFunc
Func _PPT_SlideAddTextBox(ByRef $obj, $left = 0, $top = 0, $width = 100, $height = 100)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.Shapes.AddTextBox(1, $left, $top, $width, $height)
Endif
EndFunc
Func _PPT_SlideTextFrameGetText($obj, $intSlide, $intTextFrame)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
Local $text = $obj.Slides.Item($intSlide).Shapes.Range($intTextFrame).TextFrame.TextRange.Text
Return $text
Endif
EndFunc
Func _PPT_SlideShapeCount($obj, $intSlide)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
Return $obj.Slides.Item($intSlide).Shapes.Range.Count
Endif
EndFunc
Func _PPT_SlideCreate($obj, $index, $layout)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
Local $SlideClass = $obj.Slides.Add($index, $layout)
Return $SlideClass
Endif
EndFunc
Func _PPT_PresentationOpen($obj, $filepath)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
Local $PresInterface = $obj.Presentations
Local $objPres = $PresInterface.Open($filepath)
Return $objPres
Endif
EndFunc
Func _PPT_CreatePresentation($obj)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
Local $PropertyClass = $obj.Presentations
Return $PropertyClass
Endif
EndFunc
Func _PPT_PresentationAdd($obj)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
Local $objPres = $obj.Add(True) ; Presentation obj
Return $objPres
Endif
EndFunc
Func _PPT_PowerPointApp($visible = 1)
Local $obj = ObjCreate("PowerPoint.Application")
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.Visible = $visible
Return $obj
Endif
EndFunc
Func _PPT_PowerPointQuit(ByRef $obj)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
$obj.Quit()
Endif
EndFunc
Func _PPT_SlideCount($obj)
If IsObj($obj) <> 1 Then
SetError(1)
Return 0
Else
Return $obj.Slides.Count
Endif
EndFunc