If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Adding my own button to the toolbar
In article , Cor van der Bliek wrote:
That's what I'm trying to achieve. The add-in is indeed loaded. The knop macro is a simulation of the button creation with a specific image on 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.AddPictur e(FileName:="E:\Internet\Westerscheldetunnel\logoi con. 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, _ Befo=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.AddPictur e(FileName:="E:\Internet\Westerscheldetunnel\logoi con. gif", LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=353, Top:=263, Width:=14, Height:=14).Select ActiveWindow.Selection.Copy Application.CommandBars("Standard").Controls.Add Type:=msoControlButton, Befo=1 End Sub -- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com |
#2
|
|||
|
|||
Adding my own button to the toolbar
I can't figure this out Steve. I tried but nothng happens, no new button at least.
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 |
#3
|
|||
|
|||
Adding my own button to the toolbar
In article , Cor van der Bliek wrote:
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.AddPictur e(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, _ Befo=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.AddPictur e(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, Befo=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 ================================================ |
#4
|
|||
|
|||
Adding my own button to the toolbar
I finally got it working. Only partly though and strange things happen. My Add-in is there, but not showing in the list and the button only works when I start with the blank presentation.dot.
When I open a presentation by doubleclicking it, the button is not working. Loading the blank presentation.pot after the existing presentation doesn't do the trick. I have to start with the blank prsesentaion loaded! Adding the same auto_open and auto_close macro's to the existing presentation doesn't help either. Can someone help me with this puzzle. I'm using Poewerpoint 2000 on Windows 2000 Pro. |
#5
|
|||
|
|||
Adding my own button to the toolbar
In article , Cor van der Bliek wrote:
I finally got it working. Only partly though and strange things happen. My Add-in is there, but not showing in the list Which list? The one in Tools, Addins? If it's not there, it's not loaded. and the button only works when I start with the blank presentation.dot. No fair trying to confuse an old guy. That's too easy! Like shooting fish in a barrel. I wake up confused! ;-) Blank Presentation.DOT??? Do you mean Blank Presentation.PPT? It sounds as though you've saved your code to a file called Blank Presentation, not to an addin; that would explain why the presentation has to be open in order for the code to run. Adding the same auto_open and auto_close macro's to the existing presentation doesn't help either. No ... those subroutines only run when they're part of an Add-in, not when part of a PPT or POT file. Have you followed all of the steps he Create an ADD-IN with TOOLBARS that run macros http://www.rdpslides.com/pptfaq/FAQ00031.htm -- 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 ================================================ |
Thread Tools | |
Display Modes | |
|
|