Ö
Örjan Skoglösa
Hi,
I have written a little macro and saved it as a add-in. It works very
well. I´m running Office 97.
A friend of mine is running Office 2003 and he can´t use it. He says:
What could be the reason for this?
I paste the code I´m using. Of course I should first go and have a
look at the very useful site where the code comes from, but sadly I
did loose all my bookmarks some months ago.
TIA
Örjan Skoglösa
=====================
code from the macro in the ppt-file I then save as a ppa
Option Explicit
Sub Autpen()
Dim oToolbar As CommandBar
Dim oButton As CommandBarButton
Dim MyToolbar As String
' Give the toolbar a name
MyToolbar = "test"
' First, delete the toolbar if it already exists
On Error Resume Next ' so that it doesn't stop on the next line
if the toolbar doesn't exist
Application.CommandBars(MyToolbar).Delete
On Error GoTo errorhandler ' turns error handling back on
' Build the command bar
Set oToolbar = CommandBars.Add(Name:=MyToolbar,
Position:=msoBarFloating, Temporary:=True)
' Now add a button to the new toolbar
Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
' And set some of the button's properties
With oButton
.DescriptionText = "Click" 'Tooltip text when mouse if placed
over button
.Caption = "test" 'Text if Text in Icon is chosen
.OnAction = "test" 'Runs the Sub Button1() code when clicked
.Style = msoButtonCaption ' Button displays as icon, not text
or both
'.FaceId = 52 '52 is my favorite pig; chooses icon #52 from
the available Office icons
End With
' Repeat the above for as many more buttons as you need to add
' Be sure to change the .OnAction property at least for each new
button
' You can set the toolbar position and visibility here if you like
oToolbar.Top = 10
oToolbar.Left = 10
oToolbar.Visible = True
Exit Sub ' so it doesn't go on to run the errorhandler code
errorhandler:
'Just in case there is an error
MsgBox Err.Number & vbCrLf & Err.Description
End Sub
Sub Auto_Close()
'This will run when PowerPoint closes and it will delete the toolbar.
Dim oToolbar As CommandBar
Dim MyToolbar As String
' Note: MyToolbar should be the same value here as in the code
that created the toolbar
MyToolbar = "test"
On Error Resume Next
Application.CommandBars(MyToolbar).Delete
End Sub
Sub test()
MsgBox "test"
End Sub
I have written a little macro and saved it as a add-in. It works very
well. I´m running Office 97.
A friend of mine is running Office 2003 and he can´t use it. He says:
Simply adding (from Tools/Add-ons) nothing happens. If I double click on it it will open PP and "test" is there in the list of add-ons. However trying to select it I get the error message "Power Point can't load the requested add-on".
What could be the reason for this?
I paste the code I´m using. Of course I should first go and have a
look at the very useful site where the code comes from, but sadly I
did loose all my bookmarks some months ago.
TIA
Örjan Skoglösa
=====================
code from the macro in the ppt-file I then save as a ppa
Option Explicit
Sub Autpen()
Dim oToolbar As CommandBar
Dim oButton As CommandBarButton
Dim MyToolbar As String
' Give the toolbar a name
MyToolbar = "test"
' First, delete the toolbar if it already exists
On Error Resume Next ' so that it doesn't stop on the next line
if the toolbar doesn't exist
Application.CommandBars(MyToolbar).Delete
On Error GoTo errorhandler ' turns error handling back on
' Build the command bar
Set oToolbar = CommandBars.Add(Name:=MyToolbar,
Position:=msoBarFloating, Temporary:=True)
' Now add a button to the new toolbar
Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
' And set some of the button's properties
With oButton
.DescriptionText = "Click" 'Tooltip text when mouse if placed
over button
.Caption = "test" 'Text if Text in Icon is chosen
.OnAction = "test" 'Runs the Sub Button1() code when clicked
.Style = msoButtonCaption ' Button displays as icon, not text
or both
'.FaceId = 52 '52 is my favorite pig; chooses icon #52 from
the available Office icons
End With
' Repeat the above for as many more buttons as you need to add
' Be sure to change the .OnAction property at least for each new
button
' You can set the toolbar position and visibility here if you like
oToolbar.Top = 10
oToolbar.Left = 10
oToolbar.Visible = True
Exit Sub ' so it doesn't go on to run the errorhandler code
errorhandler:
'Just in case there is an error
MsgBox Err.Number & vbCrLf & Err.Description
End Sub
Sub Auto_Close()
'This will run when PowerPoint closes and it will delete the toolbar.
Dim oToolbar As CommandBar
Dim MyToolbar As String
' Note: MyToolbar should be the same value here as in the code
that created the toolbar
MyToolbar = "test"
On Error Resume Next
Application.CommandBars(MyToolbar).Delete
End Sub
Sub test()
MsgBox "test"
End Sub