PPT2000: Sample Code to Switch Arrow Pointer to Pen Pointer (267585)



The information in this article applies to:

  • Microsoft PowerPoint 2000

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:

  1. If the Control Toolbox is not visible, display it. To do this, point to Toolbars on the View menu and then click Control Toolbox.
  2. 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.
  3. Right-click the command button and click Properties on the menu that appears.
  4. 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.
  5. Right-click the command button and click View code. This starts the Visual Basic Editor.
  6. 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 "Change to Pen".
    '
             .PointerType = ppSlideShowPointerArrow
             CommandButton1.Caption = "Change to Pen"
          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 "Change to Arrow".
    '
             .PointerType = ppSlideShowPointerPen
             .PointerColor.RGB = RGB(Red:=255, Green:=0, Blue:=0)
             CommandButton1.Caption = "Change to Arrow"
          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
    					
  7. Quit the Visual Basic Editor.
  8. On the Control Toobox, click Command Button, and draw a second command button on the slide.
  9. Right-click the command button and click Properties on the menu that appears.
  10. 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.
  11. Right-click the command button and click View code. This starts the Visual Basic Editor.
  12. 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
    						
  13. Quit the Visual Basic Editor.
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.

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbdtacode kbhowto KB267585