Microsoft KB Archive/267585

= PPT2000: Sample Code to Switch Arrow Pointer to Pen Pointer =

Article ID: 267585

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft PowerPoint 2000 Standard Edition

-



This article was previously published under Q267585



SUMMARY
This article provides sample Microsoft Visual Basic for Applications code that switches the arrow pointer to a pen pointer during a slide without using the keyboard or the slide show shortcut menu. You must have some type of pointing device, such as a standard mouse, a cordless mouse, or so on, to manipulate the presentation.

The code also allows you to change the pen color.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements. NOTE: The following macro examples work only in PowerPoint. Visual Basic for Applications macros are not supported by the Microsoft PowerPoint Viewer. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

Sample Code:
 If the Control Toolbox is not visible, display it. To do this, point to Toolbars on the View menu and then click Control Toolbox. On the Control Toolbox toolbar, click Command Button. Draw a button on your slide.

NOTE: If you put this button on the slide master and the title master, it will be available on all the slides in your presentation. Right-click the command button and click Properties on the menu that appears. Change the Caption value to the following:

Change to Pen

Resize the button to fit snugly around the text. If you want, change the Font and Backcolor settings to match your presentation scheme. Close the Properties window. Right-click the command button and click View code. This starts the Visual Basic Editor.  Type the following code into the CommandButton1_Click subprocedure, which is displayed when the Visual Basic Editor is started: Private Sub CommandButton1_Click With SlideShowWindows(1).View ' ' Test to see if the pointer is already in pen mode. '     If .PointerType = ppSlideShowPointerPen Then ' ' If it is, then set it to the Arrow pointer, and ' change the caption to &quot;Change to Pen&quot;. '        .PointerType = ppSlideShowPointerArrow CommandButton1.Caption = &quot;Change to Pen&quot; Else ' ' If it isn't the Pen pointer, then change it to the Pen ' and set the Pen color to Red. Finally, change the caption ' to &quot;Change to Arrow&quot;. '        .PointerType = ppSlideShowPointerPen .PointerColor.RGB = RGB(Red:=255, Green:=0, Blue:=0) CommandButton1.Caption = &quot;Change to Arrow&quot; End If  End With End Sub Set the pen to a standard color by using a value in the following table, which lists the corresponding RGB values for standard colors.   Color       Red value     Green value     Blue value Black              0               0              0 Blue               0               0            255 Green              0             255              0 Cyan               0             255            255 Red              255               0              0 Magenta          255               0            255 Yellow           255             255              0 White            255             255            255 </li> Quit the Visual Basic Editor.</li> On the Control Toobox, click Command Button, and draw a second command button on the slide.</li> Right-click the command button and click Properties on the menu that appears.</li> Change the Caption value to the following:

Clear Drawing

Resize the button to fit snugly around the text. If you want, change the Font and Backcolor settings to match your presentation scheme. Close the Properties window.</li> Right-click the command button and click View code. This starts the Visual Basic Editor.</li>  Type the following code into the CommandButton2_Click subprocedure, which is displayed when the Visual Basic Editor is started: Private Sub CommandButton2_Click ' ' This erases what you have just drawn on the ' screen with the pen. It will not erase anything ' else on the slide. '  SlideShowWindows(1).View.EraseDrawing End Sub </li> Quit the Visual Basic Editor.</li></ol>

You will be able to switch between the arrow pointer and the pen pointer by using these buttons rather than the keyboard or the slide show shortcut menu. However, if you use the CTRL+A and CTRL+P keyboard shortcuts to switch between the arrow and pen pointer, the caption for the CommandButton1 button will not change.

Additional query words: vba howto

Keywords: kbdtacode kbhowto KB267585

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.