' --------------------------------------------------------------------- ' Copyright ©1999-2007, 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.
|