| Lescasse Consulting |
| Home Company News Prices Download Buy Forums |
|
|
TPowerpoint5 is an object designed to let you use Microsoft Powerpoint in your APL+Win applications.
You can use TPowerpoint5 to:
l programmatically create Powerpoint presentations l enhance or change Poserpoint presentations l publish Powerpoint presentations on the Web l create effects in Powerpoint presentations which would be very difficult to achieve otherwise l play Powerpoint presentations
As for other APL+Win Objects, TPowerpoint5 does not show itself by default when you instanciate it:
'ee'Świ'*Create' 'TPowerpoint5'
However you may show TPowerpoint5 as you instanciate it:
'ee'Świ'*Create' 'TPowerpoint5'('visible'1)
TPowerpoint5_1.gif
When TPowerpoint5 is instanciated, it contains no presentation. To create a presentation at the time you instanciate TPowerpoint5, use its AddPresentation method with an argument of 1 to display it.
'pp'Świ'*Create' 'TPowerpoint'('AddPresentation'1)('visible'1)
TPowerpoint5_2.gif
Finally, you may want to set TPowerpoint5 to stay on top of all other windows by setting its ontop property:
'ee'Świ'*Create' 'TPowerpoint'('AddPresentation'1)('visible'1)('ontop'1)
Please note that the AddPresentation argument has a different meaning than the TExcel AddBook method argument: it means show or hide the Presentation which the AddBook argument represent the number of workbooks to create.
Since, most of the time, you want to create TPowerpoint5 as done just above, I have created a Show method for TPowerpoint5 which does the same. Use it this way:
'ee'Świ'*Create' 'TPowerpoint' 'Show'
If you want to use Show but don’t want to let TPowerpoint5 stay on top of your other windows:
'ee'Świ'*Create' 'TPowerpoint' 'Show'('ontop'0)
A Powerpoint object contains a Presentations object which itself is made of Presentation objects.
Each Presentation may contain a Slides object which is a collection of Slide object.
Each Slide object may contain a Shapes object which is a collection of Shape objects. Shapes are what you ultimately see in slides.
There also is a master slide object (internally called SlideMaster) which serves as a template for each slide you are creating.
Therefore, if you want to have a consistent way of presenting and formatting your slides throughout your presentation, you should set properties on the SlideMaster object.
You indicate that you want to set properties on the SlideMaster object by selecting slide 0:
'pp'Świ'slide'0
Here is the set of TPowerpoint5 properties:
70 TELPRINTś'pp'Świ'Properties' class help ontop visible where
and methods:
70 TELPRINTś'pp'Świ'Methods' AddPresentation First Next ShapeDelete AddSlide Hide Open ShapeSelect AddTable Last OrigScale Show CellBackColor Load Previous Slide Close MoveBottom Quit SlideTitle ColumnWidths MoveLeft Run Title ComputeColors MoveRight RunInAplWindow Titles FillTable MoveTop Scale FillTableColors NbSlides ScaleHeight FindTables New ScaleWidth
There are several ways a TPowerpoint5 object can be deleted.
First you may programmatically call its Quit method:
Second, you may close the instance of TPowerpoint5 with your mouse by simply closing Powerpoint.
However this does not remove Powerpoint from memory.
You must be careful to NOT create a new instance of TPowerpoint5 without having first completely remove the first instance from memory using the Quit method. If you fail to do so, methods like the Quit method may no longer work.
So, the good rule is: whenever you want to create an instance of TPowerpoint5, first delete any instance of the same name which may already be running.
For this purpose I have create the small handy utility function Powerpoint, which reads as follows:
’ Powerpoint [1] :if 0¬˝'pp'Świ'*self' Ş 'pp'Świ'Quit' Ş :end [2] 0 0˝'pp'Świ'*Create' 'TPowerpoint' 'Show' 'SessionFocus'
’
Whenever you create an instance of TPowerpoint5 use instructions similar as the ones in function Powerpoint.
Note that the SessionFocus method is not a TPowerpoint5 method: it is inherited from TCommon and returns the focus to the APL session as soon as TPowerpoint5 is instanciated.
To open an existing Powerpoint presentation, call the Open method with the full name of the .ppt presentation file:
'pp'Świ'Open' 'c:\aplwin\objects\aplwin95.ppt'
TPowerpoint5_3.gif
Creating a New Slide
Let’s first start with a new instance of TPowerpoint5.
Powerpoint
You may add a new slide to your presentation with the AddSlide method:
'pp'Świ'AddSlide'1 12
TPowerpoint5_4.gif
The first AddSlide argument is the slide number. The slide is added just before the slide you specify. If there is no slide in the presentation yet, use 1 to create the first slide as we did above. If you try to use a slide out of range, you get an error:
'pp'Świ'AddSlide'5 12 ŚWI ERROR: Microsoft PowerPoint 2002 exception 80048240 Slides.Add : Integer out of range. 5 is not in Index's valid range of 1 to 3. TPowerpoint[159] Świ( '*xActivePresentation.Slides.XAdd>:slide'),Śwarg[2 3] ^
Slide 5 cannot be added because there is no slide 4 yet.
The second argument is the type of slide you want to create. Use a number from the following table:
Using 12 as the second argument as we did above, adds a blank slide.
Now let’s add a slide with a title:
'pp'Świ'AddSlide'2 1
TPowerpoint5_5.gif
If you try to add a slide again before slide 2, you will insert a slide between slide 1 and slide 2. Let’s add a slide with a table (type 4) in it:
'pp'Świ'AddSlide'2 4
TPowerpoint5_6.gif
Still one more example : let’s create a slide with vertical text and a clipart:
'pp'Świ'AddSlide'4 26
TPowerpoint5_7.gif
Thus, with the simple AddSlide method you can quickly create all the slides of your presentation.
You will then need to populate them with the correct data, images, titles, tables, objects and format them using foreground and background colors, etc.
Remember: use an index of 1 to insert a slide before slide 1 and an index of 1+number of slides to insert a slide at the end of the currently existing slides.
Run the NbSlides method to know how many slides there are in your presentation:
'pp'Świ'NbSlides' 4
To delete a slide use the DeleteSlide method passing to it the slide number.
'pp'Świ'DeleteSlide'3
When you delete slide N, the slide which becomes active is the new slide which gets number N. If no such slide, it is the last slide in the presentation which becomes active.
You may also delete all slides in the presentation using the DeleteAllSlides method:
'pp'Świ'DeleteAllSlides'
Before you can work on a slide, you must select it and activate it with the slide property.
Example:
'pp'Świ'slide'3
This selects slide 3 and activates it.
Slide Background Color
You may change the slide background color using the slidebackcolor property:
'pp'Świ'slidebackcolor'(255 255 153)
Slide Background Pattern
You may change the slide background pattern by using the slidepattern property. Be sure to first select the slide you want to work on:
'pp'Świ'slide'2
There are 48 possible patterns whose names are:
Let’s select pattern 40:
'pp'Świ'slidepattern'10
TPowerpoint5_8.gif
Slide Color Gradient
To enhance the look of your slide you may apply a color gradient to it:
'pp'Świ'slidegradient'3 4 7
The first parameter is the type of gradient to be chosen among:
The second parameter can be 1 to 4 except for msoGradientFromTitle and msoGradientFromCenter where it can only be 1 or 2.
The third parameter is the PresetGradientType to be chosen among:
TPowerpoint5_9.gif
Slide Texture
You may set a texture to the background of your slide by setting its slidetexture property as follows:
'pp'Świ'slidetexture'5
where the slidetexture argument is a preset texture number (from 1 to 24).
Possible textures are:
The previous example would display the following slide texture:
TPowerpoint5_10.gif
Even more spectacular is the possibility to apply a template to your presentation.
This is very easily done using the template property.
You must simply pass the complete file name of a .POT template file. Example:
'pp'Świ'template' 'C:\Program Files\Microsoft Office\Templates\Presentation Designs\Mountain Top.pot'
This result in ALL the slides in your presentation to adopt the specified template.
TPowerpoint5_11.gif
Note that you can omit the path of your template file if it is:
C:\Program Files\Microsoft Office\Templates\Presentation Designs\
This is where you normally find all the.POT template files delivered with Powerpoint.
Thus, we could have written the last example as:
'pp'Świ'template' 'Mountain Top.pot'
Just as you can select a slide to work with the slide and change its properties, you can select a Shape in a slide to work with it and get or set its properties.
Selecting A Shape
To select a shape in a slide, simply use the shape property, passing to it the shape number:
'pp'Świ'shape'2
This means: select shape number 2 in the currently active slide.
When you select a shape this way, you immediately see which shape was selected.
Example:
This allows you to visually check that you are have selected the right shape.
Selecting a shape is a prerequisite to starting to get or set its properties or running its methods.
Querying the Number of Shapes in Your Slide
Run the NbShapes method to know how many shapes there are in the currently active slide.
'pp'Świ'NbShapes' 2
Deleting a Shape
To remove a shape from a slide, use the DeleteShape method and pass it the number of the shape to delete:
'pp'Świ'DeleteShape'2
Deleting All Shapes in A Slide
Use the DeleteAllShapes to remove all shapes from a slide:
'pp'Świ'DeleteAllShapes'
Adding New Shapes
All kinds of new shapes can be added to a presentation.
Let’s first create a new blank slide:
'pp'Świ'AddSlide'5 12
Use the AddTextBox method to add a text box to the presentation:
'pp'Świ'AddTextBox'0 50 100 100 200 'This is a TextBox' 1
Note that this method returns the shape number of the just created shape and selects it.
Similarly an image shape can be added to the slide by using the AddPicture method:
'pp'Świ'AddPicture' 'C:\Program Files\Common Files\Borland Shared\Images\Splash\16Color\earth.bmp'200 200 150 200 2
TPowerpoint5_14.gif
Changing the Slide Title
Use the slidetitle property to change the slide title:
'pp'Świ'slide'2 'pp'Świ'slidetitle' 'APL+Win 5.0'
TPowerpoint5_15.gif
Working with Text in Shapes
First select the shape you want to work with. Then set its shapetext property.
Example:
'pp'Świ'slide'2 'pp'Świ'shape'1 'pp'Świ'shapetext' 'APL+Win 5.0 Enhancements' 'pp'Świ'shape'2 'pp'Świ'shapetext'('New Registry Object',Śtcnl,'Elastic Workspaces',Śtcnl,'APL+Draw OCX Drawing Faclity')
TPowerpoint5_16.gif
It is therefore extremely easy to programmatically create a complete presentation with text slides from APL.
Changing Fonts
Once you have installed text in your shape, you may want to change font name, size or attribute (bold, italic, etc.) for the whole text or only part of it.
Text in a shape is made of Paragraphs and each Paragraph is made of Words.
An item in a list is considered to be a paragraph.
For example, in the above slide “APL+Win 5.0 Enhancements” is a paragraph, just like “Elastic Workspaces”.
You use the following properties to work with fonts:
All these properties accept 3 arguments:
the first one is the paragraph number (or 0 to mean all paragraphs in the shape) the second one is the word number in the paragraph (or 0 for all words in the paragraph) the third one is the new value
Examples:
Once you have work a bit defining a new presentation, you want to save it.
If it’s a new presentation, you must use the SaveAs method to first save your presentation.
l The first SaveAs argument is the complete file name l The
2nd SaveAs argument is the file format, one of:
Headers are currently not available for TPowerpoint5.
Footers are defined using the footer, the footerdate and footerslide properties.
Footers are only defined with TPowerpoint5 at the SlideMaster level, i.e. they apply to all slides in your presentation.
Example:
The possible date formats are:
Once your presentation is ready, you can run it using the Run method.
This hides the TPowerpoint5 window. At the end of the presentation it is your responsibility to show it back again using the Hide method with an argument of 0.
'pp'Świ'Run'
Click the screen to move from one slide to the next one.
At the end of the presentation, do:
'pp'Świ'Hide'0
to show the TPowerpoint5 window.
You can optionally use several arguments to the Run method: they are described below:
Example:
'pp'Świ'Run'1 2 3 150 200 546 728 1
TPowerpoint5_30.gif
The Powerpoint presentation showing slides 2 and 3 (here slide 2) is displayed on the screen at the specified location, in a window with no border. Just click on the slide to move to next slide or to show the next slide item.
Here is how it gets displayed on the screen.:
TPowerpoint5_31.gif
Even more spectacular is the possibility to display your Powerpoint presentations embedded into your APL forms.
To do so you must use the RunInAplWindow method which accepts 4 or 5 arguments
The following simple function demonstrates how you could display a Powerpoint presentation in a TFrame5 object embedded in a TPage5 object in a TForm5:
’ PowerpointDemo;Z;text1;text2;Śwself [1] :if 0=˝'pp'Świ'*self' Ş PpExample Ş :end [2] Śwself„'pptdemo'Świ'*Create' 'TForm5'('*size'450 650)('ontop'1) [3] Z„Świ'*icon' 'c:\aplwin\objects\aplwin.ico' [4] Z„Świ'*caption' 'Powerpoint Presentation in an APL Window'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||