Powerpoint: Difference between revisions

From AutoIt Wiki
Jump to navigation Jump to search
No edit summary
Line 142: Line 142:
=== Meeting Item ===
=== Meeting Item ===
Further information about wrapper functions plus tips & tricks for meeting items: [[OutlookEX UDF - Meeting Item]]
Further information about wrapper functions plus tips & tricks for meeting items: [[OutlookEX UDF - Meeting Item]]
== Known issues ==
Some features of Microsoft's Office products are proprietary and cannot readily be manipulated.<br>
Sometimes workarounds are required. [[Known issues with Microsoft Office automation.|This page]] is dedicated to identifying those issues, provide explanations and list solutions or workarounds.
=== Attachment in GMail ===
"When I attach a PDF with the Outlook UDF the attachment gets renamed to 'noname' with no extension".<br />
When you search the web for "gmail attachment noname" you get a lot of hits. Seems it is a problem with GMail.
=== HTML body shown as WINMAIL.DAT ===
"I have successfully inserted an HTML body and a PDF attachment. However, Thunderbird and SquirrelMail clients do not show the HTML and only show a WINMAIL.DAT attachment."<br />
This has been discussed [https://www.autoitscript.com/forum/topic/158418-outlookex-udf-help-support-iii/?page=35#comment-1345813 here].<br>
Another good explanation including Transport Neutral Encapsulation Format (TNEF) can be found [https://support.microsoft.com/en-us/help/290809/how-e-mail-message-formats-affect-internet-e-mail-messages-in-outlook here].
=== Mail in RTF format ===
I think RTF is not supported by Outlook and was introduced by "accident". Described in this - quite old - [http://www.vbforums.com/showthread.php?229250-RESOLVED-Write-RTF-to-outlook-mailitem&p=1352438&viewfull=1#post1352438 thread].


== Debugging ==
== Debugging ==

Revision as of 07:12, 1 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:

  • _PPT_Open
  • Some functions allow to process just a single Slide and others allow a range of Slides.
    The the description of the specific function.
  • Some functions allow to process just a single Shape and others allow a range of Shapes.
    The the description of the specific function.
  • _PPT_Close

PowerPoint

Terms
  • An event is an activity that lasts 24 hours or longer.
  • An appointment is an activity that does not involve reserving resources or inviting other people.
  • A meeting is an appointment for which you reserve a period of time, invite people to, or reserve resources.

A more detailed description of this terms can be found here.

Concepts

You can get an overview of the concepts of PowerPoint on 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..
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
The following example (reduced to the minimum) shows how to handle events:

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

More examples come with the UDF.

Object model

The Outlook object model is described 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:

Syntax Folder you access
"rootfolder\subfolder\...\subfolder" any public folder or any folder of the current user (replace rootfolder with * to access the root folder of your mailbox)
"\\rootfolder" default folder of another user (class specified by $iOL_FolderType) (replace "rootfolder" with "*" to access your mailbox)
"\\rootfolder\\subfolder\...\subfolder" subfolder of the default folder of another user (class specified by $iOL_FolderType)
"\\rootfolder\subfolder\..\subfolder" subfolder of another user
"" default folder of the current user (class specified by $iOL_FolderType)
"\subfolder" 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:

$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.")

or

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)

Empty properties in the passed array are ignored.

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.

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.
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.
_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.
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

Example scripts which describe more than a single function of the UDF are prefixed with _OL_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 find items: OutlookEX UDF - Find Items

Forward an Item

Further information on how to forward items: OutlookEX UDF - Forward Items

Item specific pages

The following pages contain information for each of the Outlook item types supported by the OutlookEX UDF.

Appointment Item

Further information about wrapper functions plus tips & tricks for appointment items: OutlookEX UDF - Appointment Item

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

Debugging

Running script as Administrator

It seems that the process that starts or hooks into Outlook needs to be run with the same permissions as Outlook.

You get the following error when setting _OL_ErrorNotify(2):

 NumberHex = 800401E3
 Number = -2147221021
 WinDesciption = Operation Unavailable

Office trial version

The trial version of Office comes without COM components. You get @error = 1 from _OL_Open.

Installing the full Office product over a trial doesn't seem to help. You need to uninstall the trial and then re-install the full product.

COM error 0x80040004 - action cancelled

Group Policy settings might deny all "unsafe" actions. Please see this post.

All kind of strange return codes

You get COM errors like

  • 0x800706BA - The RPC server is unavailable
  • 0x800706BE - The remote procedure call failed
  • or strange return values from all kind of _OL_* functions.

Outlook (starting with Outlook 2007 SP2) shuts itself down if there is no open window (which is always true when Outlook was not running when _OL_Open is being called) and there is no open reference to an Outlook item (mail, appointment ...).

This is described in the following MSDN article: "Application Shutdown Changes in Outlook 2007 SP2"

So a bug in the UDF or your code can cause Outlook to shut down prematurely.