OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy

Set Default View Add-in

PowerPoint 2000 always opens a new presentation in the Normal view. There is no way to revert this behavior except to switch to the desired view and then ensure that the the file is saved in this desired view so that the next time it is opened it will open in this view. The Set Default View add-in is specifically designed to tackle this annoyance. Load the add-in and it will add a Views combo box on the Standard Toolbar. Using which you can set the default view in which a presentation should be opened whenever you start a new presentation or open an existing one for editing.

 

 

Click here to download

 

Instructions:

Now whenever you start a new presentation or open open, it will switch to the view selected in the combo box automatically. 

Source Code


How does it work:

Trap the event when a new presentation is created or a existing presentation is opened and set the active view to the desired one. The code below, creates an event handler to trap PowerPoint events. This event handler is initialized thru the Auto_Open() routine which fires automatically when compiled into an add-in.

The ChangeView routine is invoked every time the create or open event occurs for a  presentation, within which the default view value set by the user is read from the registry and the presentation view is switched to that view.

Every time the user changes the default view, we update the value in the registry using the SetRegValue routine

Insert a Class Module (cEventClass) and paste the code given below:


 

Option Explicit
Public WithEvents PPTEvent As Application
 
Private Sub PPTEvent_NewPresentation(ByVal Pres As Presentation)
Call ChangeView(Pres)
End Sub
 
Private Sub PPTEvent_PresentationOpen(ByVal Pres As Presentation)
Call ChangeView(Pres)
End Sub
 
Sub ChangeView(Pres As Presentation)
Dim ViewType As Long
ViewType = Val(GetSetting("Views Addin", "Settings", "View", "0"))
If ViewType = 0 Then Exit Sub
If ViewType = 8 Then
    ' If the user has set the default view to Title master
    ' then check it's existence before switching to that view.

    If Pres.HasTitleMaster Then
        Pres.Windows(1).ViewType = ViewType 
    End If
Else
     Pres.Windows(1).ViewType = ViewType
End If
End Sub
Insert a code module and paste the code given below:
Option Explicit
Dim cPPTObject As New cEventClass

Sub Auto_Open()
On Error Resume Next
    Set cPPTObject.PPTEvent = Application
    Call SetViewsCombo
    CommandBars.FindControl(Tag:="msoViewsAddinCombo").Execute
End Sub

Sub Auto_Close()
On Error Resume Next
    Set cPPTObject.PPTEvent = Nothing
    Set cPPTObject = Nothing
    CommandBars.FindControl(Tag:="msoViewsAddinCombo").Delete
End Sub
 
Sub SetViewsCombo()
Dim oCmbMenu As CommandBarComboBox
 
    Set oCmbMenu = CommandBars.FindControl(Tag:="msoViewsAddinCombo")
    If oCmbMenu Is Nothing Then
        Set oCmbMenu = CommandBars("Standard").Controls.Add(msoControlComboBox, , , , True)
    End If
With oCmbMenu
    .Clear
    .Tag = "msoViewsAddinCombo"
    .Caption = "Default"
    .Style = msoComboLabel
    .AddItem "View saved in the file"
    .AddItem "Slide view"
    .AddItem "Slide master view"
    .AddItem "Notes page view"
    .AddItem "Handout master view"
    .AddItem "Notes master view"
    .AddItem "Outline view"
    .AddItem "Slide sorter view"
    .AddItem "Title master view"
    .AddItem "Normal view"
    If Val(Application.Version) > 9 Then
        .AddItem "Print preview view"
    End If
    .ListIndex = Val(GetSetting("Views Addin", "Settings", "View", "0")) + 1
    .Visible = True
    .Width = 175
    .OnAction = "SetRegValue"
End With
End Sub

Sub SetRegValue()
Dim oCmbMenu As CommandBarComboBox
Set oCmbMenu = CommandBars.ActionControl
SaveSetting "Views Addin", "Settings", "View", CStr(oCmbMenu.ListIndex - 1)
End Sub


Copyright 1999-2018 (c) Shyam Pillai. All rights reserved.