I can't figure this out Steve. I tried but nothng happens, no new button at least.
Have you made an Add-in of this, or are you just running the code from within the VBA Editor?
Where is the link with the macro (ToonSjablonen), which should be activated by pressing the new button.
P.S. ToonSjablonen is Dutch for Show Templates
This line in your code tells PowerPoint to run the subroutine "ToonSjablonen" when you click the
button:
NewControl.OnAction = "ToonSjablonen"
You need to have a Sub ToonSjablonen() in the same add-in or presentation for PPT to be able to
find it.
Here's what I think the problem is, if I understand you correctly:
Your Auto_Open routine runs at startup and creates the button
Your Auto_Close routine deletes it
Nothing in Auto_Open applied the button icon you want, so it's a gray button.
You may have applied it once while testing, but the Auto_Close deleted it.
Try adding something like this to Auto_Open after creating/naming NewControl
(watch line breaks)
' First start a new presentation
Dim oSh as Shape
Set oSh = Call
ActiveWindow.Selection.SlideRange.Shapes.AddPicture(FileName:="E:\Internet\Westerscheldetunnel\lo
goicon.
gif", _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=353, Top:=263, Width:=14, Height:=14)
osh.Copy
NewControl.PasteFace
oSh.Delete
' and close the presentation
This is what it reads:
Sub Auto_Open()
'
' De macro is opgenomen op 11-5-2004 door C. van der Bliek.
'
Dim NewControl As CommandBarControl
' Store an object reference to a command bar.
Dim FileMenu As CommandBars
' Figure out where to place the menu choice.
Set FileMenu = Application.CommandBars
' Create the menu choice. The choice is created in the first
' position in the Tools menu.
Set NewControl = FileMenu("File").Controls.Add _
(Type:=msoControlButton, _
Before:=2)
' Name the command.
NewControl.Caption = "WST sjablonen"
' Connect the menu choice to your macro. The OnAction property
' should be set to the name of your macro.
NewControl.OnAction = "ToonSjablonen"
End Sub
Sub Auto_Close()
Dim oControl As CommandBarControl
Dim FileMenu As CommandBars
' Get an object reference to a command bar.
Set FileMenu = Application.CommandBars
' Loop through the commands on the tools menu.
For Each oControl In FileMenu("File").Controls
' Check to see whether the comand exists.
If oControl.Caption = "WST sjablonen" Then
' Check to see whether action setting is set to ChangeView.
If oControl.OnAction = "ToonSjablonen" Then
' Remove the command from the menu.
oControl.Delete
End If
End If
Next oControl
End Sub
Sub knop()
'
' De macro is opgenomen op 11-5-2004 door C. van der Bliek.
'
ActiveWindow.Selection.SlideRange.Shapes.AddPicture(FileName:="E:\Internet\Westerscheldetunnel\lo
goicon.
gif", LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=353, Top:=263, Width:=14,
Height:=14).Select
ActiveWindow.Selection.Copy
Application.CommandBars("Standard").Controls.Add Type:=msoControlButton, Before:=1
End Sub
--
Steve Rindsberg, PPT MVP
PPT FAQ:
www.pptfaq.com
PPTools:
www.pptools.com
================================================
Featured Presenter, PowerPoint Live 2004
October 10-13, San Diego, CA
www.PowerPointLive.com
================================================