|
Have you wanted to get your customized corporate
template listed on the 'New Presentation' window? This article explains
the programmatic approach as well as the registry entries required to do
it manually.
PowerPoint 2002 introduced task panes which contain
tools for specific tasks. Whether this was a step ahead or back is highly
debatable since task panes do not support key board shortcuts. However debating
the pros and cons of it does not lie in the scope of this article. I've
tried to document the NewPresentation object which allows access to the
'New Presentation' task pane items. The NewPresentation property documentation
leaves much to be desired. It does enumerate the arguments that can be passed
to the Add and Remove methods.
The 'New Presentation' task pane is divided into
sections namely 'Open Presentation', 'New', 'New From Existing Presentation',
'New From Template' and an unnamed last section which appears at the bottom
area of the task pane. Each of these sections have an associated index value
from 0 to 4. Your entry is placed in the appropriate section of the task
pane based on this value.
Similarly the Action argument can be either 0
(Open existing presentation) or 1 (Create a New presentation). When the
user clicks on your entry on the task pane, PowerPoint looks at the action
associated with that entry and performs the stated operation.
|
|
' --------------------------------------------------------------------- ' Copyright ©1999-2022, Shyam Pillai, All Rights Reserved. ' --------------------------------------------------------------------- ' You are free to use this code within your own applications, add-ins, ' documents etc but you are expressly forbidden from selling or ' otherwise distributing this source code without prior consent. ' This includes both posting free demo projects made from this ' code as well as reproducing the code in text or html format.
' You may include acknowledgement to the author and a link to this site. ' ----------------------------------------------------------------------
Enum SectionValues
enumOpenPresentation = 0 enumNew = 1
enumNewFromExistingPresentation = 2
enumNewFromTemplate = 3 enumLastSection = 4 End
Enum Enum ActionValues enumOpenExisting = 0
enumCreateNew = 1 End Enum Sub AddToTaskPane(FileName As String,
DisplayName As String, _
Optional Section As SectionValues, _
Optional Action As ActionValues, _
Optional UpdateTaskPane As Boolean = True) Call
Application.NewPresentation.Add(FileName, Section, DisplayName, Action)
' Only way to force a task pane refresh
is to hide it and unhide it. Tacky. If UpdateTaskPane Then
CommandBars("Task Pane").Visible = False
CommandBars("Task Pane").Visible = True End If End Sub
Sub
RemoveFromTaskPane(FileName As String, DisplayName As String, _
Optional Section As SectionValues = enumLastSection, _
Optional Action As ActionValues = enumCreateNew, _
Optional UpdateTaskPane As Boolean = True) Call
Application.NewPresentation.Remove(FileName, Section, DisplayName,
Action) If UpdateTaskPane Then
CommandBars("Task Pane").Visible = False
CommandBars("Task Pane").Visible = True End If End Sub
Sub
SampleTest() Call AddToTaskPane("C:\LegalPresentation.pot", _
"Company Template [Legal]", _
enumNewFromTemplate, _
enumCreateNew) End Sub
While the items can be added to the task pane
using code, it can also be achieved by editing the registry. Let us take
a look at the registry entries made after we run the SampleTest routine.
Notice a new key entry has been created: HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\PowerPoint\New
Presentation\Custom1 with four items in it namely Action, DisplayName, Filename,
Section corresponding to the values passed by our routine.
When you add another item to the task pane it's
information will be stored in the key: HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\PowerPoint\New
Presentation\Custom2 and so on.
Let's recreate the same item thru the registry
editor assuming that we are performing the task on a clean system.
-
Make
sure PowerPoint isn't running.
-
Launch Regedit (Start | Run | Type 'Regedit'
and press <ENTER>)
-
Navigate to HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\PowerPoint\
note that 10.0 represents PowerPoint 2002 if you are using PowerPoint
2003 navigate to HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\PowerPoint\
-
Right-click on 'PowerPoint' and select New
Key. Name this key 'New Presentation'
-
Select the 'New Presentation' Key.
-
Right-click on 'New Presentation' and select
New Key. Name this key 'Custom1'
-
Right-click on 'Custom2' key and select New
| DWORD value and name this 'Action' set to a data value of the action
you wish to perform i.e. 1 indicating that we wish to create a new presentation
vased on this template/presentation.
-
Right-click on 'Custom2' key and select New
| String value and name this 'DisplayName' set to a data value of the
text that you wish to see on the task pane i.e. 'Company Template [Legal]'.
-
Right-click on 'Custom2' key and select New
| String value and name this 'Filename' set to a data value pointing
to the location of the presentation/template i.e. C:\LegalPresentation.pot.
-
Right-click on 'Custom2' key and select New
| DWORD value and name this 'Section' set to a data value matching the
index of the section in which you want it to appear i.e. 3 indicating
that you want it to appear in the 'New from template' section.
-
Quit Regedit
-
Launch PowerPoint. The new item 'Company
Template [Legal]' will appear in the 'New Presentation' task pane.
|