Log in

View Full Version : Solved: PPT 2003 Add-in does not work



evamads
10-07-2009, 07:25 AM
I have written a macro that creates a toolbar with 3 buttons, and a macro for each button. I save it as a .ppa, and add it via Tools > Add Ins. Works fine with me.

Then I send the .ppa to someone else and have them add it via Tools > Add Ins, but now it does not work :banghead:

Any suggestions?

/evamads

evamads
10-07-2009, 07:26 AM
Oh, forgot to mention that macro security is Low...

John Wilson
10-07-2009, 08:38 AM
Maybe post some code??

evamads
10-08-2009, 12:23 AM
Sure:

Module1:
Dim aEventClass As egaEventClass
Sub Auto_Open()
Set aEventClass = New egaEventClass ' Hook Application events i Class_Initialize
End Sub

Class Module egaEventClass:

Public WithEvents App As Application
Private Sub App_NewPresentation(ByVal Pres As Presentation)
' MsgBox "Makroen kører"
On Error Resume Next
Application.CommandBars("GF speciel").Delete
On Error GoTo 0
Application.CommandBars.Add Name:="GF speciel", Position:=msoBarFloating, temporary:=True

With Application
.CommandBars("GF speciel").Visible = True
End With

Set newItem1 = CommandBars("GF speciel").Controls.Add(Type:=msoControlButton)
With newItem1
.BeginGroup = False
.Caption = "Nyt afsnitsdias"
.OnAction = "NytAfsnitDias"
.TooltipText = "Nyt afsnit dias"
.Style = msoButtonCaption
End With
Set newItem2 = CommandBars("GF speciel").Controls.Add(Type:=msoControlButton)
With newItem2
.BeginGroup = False
.Caption = "Nyt tekst dias"
.OnAction = "NytTekstDias"
.TooltipText = "Nyt tekst dias"
.Style = msoButtonCaption
End With
Set newItem3 = CommandBars("GF speciel").Controls.Add(Type:=msoControlButton)
With newItem3
.BeginGroup = False
.Caption = "Fjern punkttegn"
.OnAction = "RemoveBullet"
.TooltipText = "Fjern punkttegn"
.Style = msoButtonCaption
End With
End Sub
Private Sub Class_Initialize()
Set App = Application ' Hook events
End Sub

... the big question is, why does it run on my computer and not on the other?

/evamads

John Wilson
10-08-2009, 01:59 AM
Is there some reason to use Class modules? (maybe something I can't see here)

In any case you don't need them to create the toolbar.

Also Declare the CommandBar Button variables

Try this

Dim NewItem1 As CommandBarButton
Dim NewItem2 As CommandBarButton
Dim NewItem3 As CommandBarButton



Sub auto_open()
On Error Resume Next
Application.CommandBars("GF speciel").Delete
On Error GoTo 0
Application.CommandBars.Add Name:="GF speciel", Position:=msoBarFloating, temporary:=True

With Application
.CommandBars("GF speciel").Visible = True
End With

Set NewItem1 = CommandBars("GF speciel").Controls.Add(Type:=msoControlButton)
With NewItem1
.BeginGroup = False
.Caption = "Nyt afsnitsdias"
.OnAction = "NytAfsnitDias"
.TooltipText = "Nyt afsnit dias"
.Style = msoButtonCaption
End With
Set NewItem2 = CommandBars("GF speciel").Controls.Add(Type:=msoControlButton)
With NewItem2
.BeginGroup = False
.Caption = "Nyt tekst dias"
.OnAction = "NytTekstDias"
.TooltipText = "Nyt tekst dias"
.Style = msoButtonCaption
End With
Set NewItem3 = CommandBars("GF speciel").Controls.Add(Type:=msoControlButton)
With NewItem3
.BeginGroup = False
.Caption = "Fjern punkttegn"
.OnAction = "RemoveBullet"
.TooltipText = "Fjern punkttegn"
.Style = msoButtonCaption
End With

End Sub

evamads
10-08-2009, 06:18 AM
It works ! :thumb Thank you very much for your help.

... and no, there is no reason to use the class module (just was not sure).

/evamads