The information in this article applies to:
SUMMARYDuring a slide show, you may want to change the positions of an object or hide and display it on command. This article demonstrates one way to do this with Microsoft Visual Basic for Applications (VBA) macros. MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.asp Getting Object NamesAlthough you can work with the index position for visible objects, if you plan to hide and make visible a shape or text frame, you need to find out the name of the object.
Changing The Position Of ObjectsThe following code fragment demonstrates how to change the location of a shape to another location on the slide:
All objects' positions are referenced by their upper-left corner; these values are in points (72 points per inch). The standard PowerPoint presentation is 720 points wide, and 540 points tall. The upper-left corner is Left = 0, and Top = 0.The following sample macro moves "Rectangle 2" from the lower-right corner of the slide, to the upper-left corner of the slide:
Another way to move an object is to rotate it around its center. This can make for some interesting effects. The following code sample demonstrates how you could do it:
Rotation is a read/write property. As input, it takes a number of type Single as the number of degrees rotation you want to apply to the shape. A positive value rotates the object clockwise, a negative value rotates it counterclockwise. In the previous code sample, the object is rotated clockwise.
Hiding and Showing ObjectsAnother way to alter a slide object is to make it appear or disappear. To do this, you simply alter the Visible property of the shape:
Again, please note that if you make an object invisible, the only way you can make it visible directly is by using the name of the object, instead of using the index value assigned to the shape; the index value can change if the z-order position of the object changes.
Additional query words: vba
Keywords : kbdta kbdtacode OffVBA KbVBA |
Last Reviewed: October 8, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |