PPT2002: Incorrect VBA ViewType Returned for Slide Master View (285436)



The information in this article applies to:

  • Microsoft PowerPoint 2002

This article was previously published under Q285436

SYMPTOMS

When you use a Microsoft Visual Basic for Applications (VBA) macro in Microsoft PowerPoint to determine the current view type, the results for a slide master may incorrectly indicate a Normal view.

CAUSE

This behavior occurs because of the way that the ActiveWindow.View.Type property handles all views that have multiple panes. For all views that have multiple panes, ActiveWindow.View.Type returns ppViewNormal, or a value of 9.

RESOLUTION

Microsoft 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 Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site: For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site: 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: The following sample macro allows you to determine which view PowerPoint is currently in:
Sub DisplayViewType()
   Dim typCurrentViewType As PpViewType
   Dim strCurrentViewType As String
   '
   ' First determine if the current view is the Normal View.
   '
   If Application.ActiveWindow.View.Type = ppViewNormal Then
   '
   ' If it is, then the second item in the Panes collection
   ' will be the actual view we wish to return a value on.
   '
      typCurrentViewType = ActiveWindow.Panes.Item(2).ViewType
   Else
   '
   ' If it is not, then return the ViewType for the active
   ' window.
   '
      typCurrentViewType = Application.ActiveWindow.View.Type
   End If
   '
   ' Based on the view type, assign the corresponding
   ' description to the string variable.
   '
   Select Case typCurrentViewType
      Case ppViewSlide
         strCurrentViewType = "Slide"
      Case ppViewSlideMaster
         strCurrentViewType = "Slide Master"
      Case ppViewNotesPage
         strCurrentViewType = "Notes Page"
      Case ppViewHandoutMaster
         strCurrentViewType = "Handout Master"
      Case ppViewNotesMaster
         strCurrentViewType = "Notes Master"
      Case ppViewOutline
         strCurrentViewType = "Outline"
      Case ppViewSlideSorter
         strCurrentViewType = "Slide Sorter"
      Case ppViewTitleMaster
         strCurrentViewType = "Title Master"
      Case ppViewNormal
         strCurrentViewType = "Normal"
      Case ppViewPrintPreview
         strCurrentViewType = "Print Preview"
      Case ppViewThumbnails
         strCurrentViewType = "Thumbnails"
      Case ppViewMasterThumbnails
         strCurrentViewType = "Thumbnails Master"
   End Select
   '
   ' Display the ViewType value.
   '
   MsgBox strCurrentViewType & " View"
End Sub
				

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbpending kbprb KB285436