Powerpoint: Difference between revisions

From AutoIt Wiki
Jump to navigation Jump to search
 
(18 intermediate revisions by the same user not shown)
Line 8: Line 8:
The PowerPoint UDF is based on the following concept:
The PowerPoint UDF is based on the following concept:


* _PPT_Open
* Use function ''_PPT_Open'' as the first step in your script to start up PowerPoint or to connect to a running instance.
* Some functions allow to process just a single Slide and others allow a range of Slides.<br>The the description of the specific function.
* Some functions allow to process just a single Slide and others allow a range of Slides.
* Some functions allow to process just a single Shape and others allow a range of Shapes.<br>The the description of the specific function.
** The UDF always uses the SlideRange object when working with Slides.<br>Use function ''_PPT_SlideRangeSet'' to specify the Slides to process, then call a function and pass the SlideRange as parameter.
 
** For details please check the description of the specific function.
* _PPT_Close
* Some functions allow to process just a single Shape and others allow a range of Shapes.
 
** The UDF always uses the ShapeRange object when working with Shapes.<br>Use function ''_PPT_ShapeRangeSet'' to specify the Shapes to process, then call a function and pass the ShapeRange as parameter.
--------------------
** For details please check the description of the specific function.
* Use function ''_PPT_Close'' as the last step in your script to shutdown PowerPoint or to release the connection to a running instance.


=== PowerPoint ===
=== PowerPoint ===


===== Terms =====
===== Definitions =====
* An '''event''' is an activity that lasts 24 hours or longer.
* '''HandoutMaster''': The Handout Master controls what the slides on the audience handouts will look like. The slide image placeholders show where slides are placed on the master.
* An '''appointment''' is an activity that does not involve reserving resources or inviting other people.
* '''NotesMaster''': The Notes Master lets you alter the appearance of the “Notes Page” presentation view.
* A '''meeting''' is an appointment for which you reserve a period of time, invite people to, or reserve resources.
* '''ShapeRange''': Represents a subset of the Shapes in a Slide.
A more detailed description of this terms can be found [http://www.knowledgewave.com/blog/msoffice/outlook/whats-the-dif-events-appointments-and-meeting-requests-in-microsoft-outlook-2013.html here].
* '''SlideMaster''': A Slide Master is the top slide in a hierarchy of slides that stores information about the theme and slide layouts of a presentation, including the background, color, fonts, effects, placeholder sizes, and positioning.  
 
* The '''SlideNumber''' property of a Slide object is the actual number that appears in the lower-right corner of the Slide when you display slide numbers.<br> This number is determined by the number of the Slide within the Presentation (the '''SlideIndex''' property value) and the starting slide number for the Presentation (the FirstSlideNumber property value).
* '''SlideRange''': Represents a subset of the Slides in a Presentation.
* '''Template''': A template is a theme plus some content for a specific purpose—such as a sales presentation, a business plan, or a classroom lesson.<br>So a template has design elements that work together (colors, fonts, backgrounds, effects) and boilerplate content that you augment to tell your story. Details can be found [https://support.microsoft.com/en-us/office/understand-the-difference-between-powerpoint-templates-and-themes-e2408e10-e015-43b3-8b29-b99d128ae448#bm1 here].
* '''Theme''': A theme is a predefined set of colors, fonts, and visual effects that you apply to your slides for a unified, professional look. Details can be found [https://support.microsoft.com/en-us/office/understand-the-difference-between-powerpoint-templates-and-themes-e2408e10-e015-43b3-8b29-b99d128ae448 here].
* '''TitleMaster''': The Title Master controls "title" slides. Typically just the first slide of your presentation.
===== Concepts =====
===== Concepts =====
You can get an overview of the concepts of PowerPoint on [https://docs.microsoft.com/en-us/office/vba/powerpoint/concepts/concepts-powerpoint-vba-reference this website].
You can get an overview of the concepts of PowerPoint on [https://docs.microsoft.com/en-us/office/vba/powerpoint/concepts/concepts-powerpoint-vba-reference this website].
====== Events ======
PowerPoint provides a wide range of events through which it can notify your script that a significant change has occurred. For example, PowerPoint events can notify your script when you start a slide show..<br>
To receive notification of a significant event, write an event-handler procedure. This is a function that PowerPoint calls when the event is called. The code you put in the event handler allows your program to respond appropriately to the event and, in some cases, even lets your program cancel the default action associated with the event.
'''Responding to Events'''<br>
The following example (reduced to the minimum) shows how to handle events:
<syntaxhighlight lang="autoit">
Global $oOL = _OL_Open()
Global $oTemp = ObjEvent($oOL, "oOL_") ; Create the application-level event handler
While 1
Sleep(10)
WEnd
Func oOL_NewMailEx($sEntryIDs)
Local $iItemCount, $oItem
Local $aEntryIDs = StringSplit($sEntryIDs, ",", $STR_NOCOUNT) ; multiple EntryIDs are separated by ,
$iItemCount = UBound($aEntryIDs)
ConsoleWrite("OutlookEX UDF Example Script - " & ($iItemCount = 1 ? "new item has" : "new items have") & " arrived!" & @CRLF & @CRLF)
For $i = 0 To $iItemCount - 1
$oItem = $oOL.Session.GetItemFromID($aEntryIDs[$i], Default) ; Translate the EntryID string to the item object
ConsoleWrite("From:    " & $oItem.SenderName & @CRLF & "Subject: " & $oItem.Subject & @CRLF & "Class:  " & $oItem.Class & " (43=Mail, 53=MeetingRequest ...)" & @CRLF)
Next
EndFunc
</syntaxhighlight>
More examples come with the UDF.


===== Object model =====
===== Object model =====
The Outlook object model is described [https://docs.microsoft.com/en-us/office/vba/api/overview/outlook/object-model here].
The PowerPoint object model is described [https://docs.microsoft.com/en-us/office/vba/api/overview/powerpoint/object-model here].<br>
 
A very good description of the object model tree can be found [https://www.codevba.com/PowerPoint/ here].
== Folders ==
It does not matter where an item is stored. You can access any folder and get/create/modify items there.
 
Folders you can access:
                               
{| style="border: 1px solid darkgray" cellspacing=0 cellpadding=5px
|-
! style="border: 1px solid darkgray" | Syntax
! style="border: 1px solid darkgray" | Folder you access
|-
| style="border: 1px solid darkgray" | "rootfolder\subfolder\...\subfolder"
| style="border: 1px solid darkgray" | any '''public folder''' or any folder of the current user (replace rootfolder with * to access the root folder of your mailbox)
|-
| style="border: 1px solid darkgray" | "\\rootfolder"
| style="border: 1px solid darkgray" | default folder of '''another user''' (class specified by $iOL_FolderType) (replace "rootfolder" with "*" to access your mailbox)
|-
| style="border: 1px solid darkgray" | "\\rootfolder\\subfolder\...\subfolder"
| style="border: 1px solid darkgray" | subfolder of the default folder of '''another user''' (class specified by $iOL_FolderType)
|-
| style="border: 1px solid darkgray" | "\\rootfolder\subfolder\..\subfolder"
| style="border: 1px solid darkgray" | subfolder of '''another user'''
|-
| style="border: 1px solid darkgray" | ""
| style="border: 1px solid darkgray" | default folder of the '''current user''' (class specified by $iOL_FolderType)
|-
| style="border: 1px solid darkgray" | "\subfolder"
| style="border: 1px solid darkgray" | subfolder of the default folder of the '''current user''' (class specified by $iOL_FolderType)
|}
 
'''Note:''' You need to use different formats to access '''public folders''' and the mailbox of '''other users'''!
 
"rootfolder" is one of the following:
* Mailbox name, e.g. "John.Doe@company.com"
* Display name, e.g. "John Doe"
 
For details please see the item specific section below.
 
=== Search folders ===
As of January 2018 the UDF supports Search Folders as well. Please have a look at functions _OL_SearchFolder*.
 
== Naming pattern ==
If a method can be used for more than one item type (e.g. mail, calendar and notes) the function is called _OL_ItemXXX else the function is named like the item type e.g. _OL_CalendarXXX
 
== Call a function ==
Some functions need to accept a lot of parameters when a user needs to set many properties of an item. Let's say you want to create a mail item and pass subject, bodyformat, body and importance to the _OL_ItemCreate function.
Most functions accept up to 10 properties as parameters or an unlimited number of properties as a zero based one-dimensional array.
 
The following two examples are equivalent:
<syntaxhighlight lang="autoit">
$oItem = _OL_ItemCreate($oOutlook, $olMailItem, "*\Outlook-UDF-Test\TargetFolder\Mail", "", "Subject=TestMail", "Importance=" & $olImportanceHigh, "BodyFormat=" & $olFormatHTML, _
        "HTMLBody=Bodytext in &lt;b>bold&lt;/b><img src='cid:The_Outlook.jpg'>Embedded image.")
</syntaxhighlight>
or
<syntaxhighlight lang="autoit">
Global $aProperties[100] = ["Subject=TestMail", "Importance=" & $olImportanceHigh, "BodyFormat=" & $olFormatHTML, "HTMLBody=Bodytext in &lt;b>bold&lt;/b><img src='cid:The_Outlook.jpg'>Embedded image."]
$oItem = _OL_ItemCreate($oOutlook, $olMailItem, "*\Outlook-UDF-Test\TargetFolder\Mail", "", $aProperties)
</syntaxhighlight>
Empty properties in the passed array are ignored.


== Example Scripts ==
== Example Scripts ==
=== For single functions ===
=== For single functions ===
Every function of the UDF comes with an example script (except internal functions). The example script is named like the function.
Every function of the UDF comes with an example script (except internal functions). The example script is named like the function.
==== Test Environment ====
Every example script calls function _OL_TestEnvironment.au3. This function creates a test environment to make sure each function delivers a predictable result independant of the system it is running on and to make sure the Outlook environment of the user is left untouched.<br>
The test environment is created as folder "Outlook-UDF-Test" plus subfolders and multiple items in your mailbox. This folders and items are manipulated by the example scripts.<br>
_OL_TestEnvironment.au3 can directly be called by the user. It then displays a GUI where the user can save some settings for the example scripts or create and delete the test environment manually.<br>The test environment is created by every example script but is not deleted after the script has ended. To remove the test environment run _OL_TestEnvironment.au3 and delete the test environment manually.


=== Extended Examples ===
=== Extended Examples ===
Example scripts which describe more than a single function of the UDF are prefixed with ''_OL_Example_''.
Example scripts which describe more than a single function of the UDF are prefixed with ''_PPT_Example_''.


== Function specific pages ==
== Function specific pages ==
The following pages contain information for the functions that can be used for many different item types.
The following pages contain information for the functions that can be used for many different item types.
=== Find an Item ===
=== Find an Item ===
Further information on how to find items: [[OutlookEX UDF - Find Items]]
Further information on how to ...: [[Link]]
=== Forward an Item ===
Further information on how to forward items: [[OutlookEX UDF - Forward Items]]


== Item specific pages ==
== Tips and Tricks ==
The following pages contain information for each of the Outlook item types supported by the OutlookEX UDF.
=== SlideShow ===
=== Appointment Item ===
To hide a Slide during a Slide Show use the following code:
Further information about wrapper functions plus tips & tricks for appointment items: [[OutlookEX UDF - Appointment Item]]
<syntaxhighlight lang="autoit">$oPresentation.Slides(x).SlideShowTransition.Hidden = True ; Replace x with the SlideIndex or Name property of the Slide to hide</syntaxhighlight>
=== Folder Item ===
Further information about how to access and manipulate folders: [[OutlookEX UDF - Folder Item]]
=== Mail Item ===
Further information about wrapper functions plus tips & tricks for mail items: [[OutlookEX UDF - Mail Item]]
=== Meeting Item ===
Further information about wrapper functions plus tips & tricks for meeting items: [[OutlookEX UDF - Meeting Item]]

Latest revision as of 14:05, 31 August 2021

This page is still a work in progress.

The PowerPoint UDF offers basic functions to control and manipulate Microsoft PowerPoint.

Concepts

UDF

The PowerPoint UDF is based on the following concept:

  • Use function _PPT_Open as the first step in your script to start up PowerPoint or to connect to a running instance.
  • Some functions allow to process just a single Slide and others allow a range of Slides.
    • The UDF always uses the SlideRange object when working with Slides.
      Use function _PPT_SlideRangeSet to specify the Slides to process, then call a function and pass the SlideRange as parameter.
    • For details please check the description of the specific function.
  • Some functions allow to process just a single Shape and others allow a range of Shapes.
    • The UDF always uses the ShapeRange object when working with Shapes.
      Use function _PPT_ShapeRangeSet to specify the Shapes to process, then call a function and pass the ShapeRange as parameter.
    • For details please check the description of the specific function.
  • Use function _PPT_Close as the last step in your script to shutdown PowerPoint or to release the connection to a running instance.

PowerPoint

Definitions
  • HandoutMaster: The Handout Master controls what the slides on the audience handouts will look like. The slide image placeholders show where slides are placed on the master.
  • NotesMaster: The Notes Master lets you alter the appearance of the “Notes Page” presentation view.
  • ShapeRange: Represents a subset of the Shapes in a Slide.
  • SlideMaster: A Slide Master is the top slide in a hierarchy of slides that stores information about the theme and slide layouts of a presentation, including the background, color, fonts, effects, placeholder sizes, and positioning.
  • The SlideNumber property of a Slide object is the actual number that appears in the lower-right corner of the Slide when you display slide numbers.
    This number is determined by the number of the Slide within the Presentation (the SlideIndex property value) and the starting slide number for the Presentation (the FirstSlideNumber property value).
  • SlideRange: Represents a subset of the Slides in a Presentation.
  • Template: A template is a theme plus some content for a specific purpose—such as a sales presentation, a business plan, or a classroom lesson.
    So a template has design elements that work together (colors, fonts, backgrounds, effects) and boilerplate content that you augment to tell your story. Details can be found here.
  • Theme: A theme is a predefined set of colors, fonts, and visual effects that you apply to your slides for a unified, professional look. Details can be found here.
  • TitleMaster: The Title Master controls "title" slides. Typically just the first slide of your presentation.
Concepts

You can get an overview of the concepts of PowerPoint on this website.

Object model

The PowerPoint object model is described here.
A very good description of the object model tree can be found here.

Example Scripts

For single functions

Every function of the UDF comes with an example script (except internal functions). The example script is named like the function.

Extended Examples

Example scripts which describe more than a single function of the UDF are prefixed with _PPT_Example_.

Function specific pages

The following pages contain information for the functions that can be used for many different item types.

Find an Item

Further information on how to ...: Link

Tips and Tricks

SlideShow

To hide a Slide during a Slide Show use the following code:

$oPresentation.Slides(x).SlideShowTransition.Hidden = True ; Replace x with the SlideIndex or Name property of the Slide to hide