M
Mike Williams
PowerPoint 2007 SP2
Pardon me if this is an unbelievably mangled problem, where it
shouldn't be. I have Excel and Word VBA experience, but none in PP.
I have a macro (UpdatePath, below) that works, that I want to run any
time I open a ppt file. Actually, it's a little more complicated. I
found info online that suggested I need an auto_open and an auto_close
procedure around it, so I added that and tweaked it. I saved the code
as an add-in (*.ppam). I loaded the add-in. It doesn't fire.
Can someone please point me towards how to fix this, or else point me
to a How-To that works? THANKS. The code:
Sub Autpen()
Dim NewControl As CommandBarControl
' Store an object reference to a command bar.
Dim ToolsMenu As CommandBars
' Figure out where to place the menu choice.
Set ToolsMenu = Application.CommandBars
' Create the menu choice. The choice is created in the first
' position in the Tools menu.
Set NewControl = ToolsMenu("Tools").Controls.Add _
(Type:=msoControlButton, _
Before:=1)
' Name the command.
NewControl.Caption = "Add Filename to Handout Footer"
' Connect the menu choice to your macro. The OnAction property
' should be set to the name of your macro.
NewControl.OnAction = "UpdatePath"
End Sub
Sub UpdatePath()
' Macro to add the path and file name to each slide's footer.
Dim PathAndName As String
Dim FeedBack As Integer
' Place a message box warning prior to replacing footers.
FeedBack = MsgBox( _
"This Macro replaces any existing text that appears " & _
"within your current footers " & Chr(13) & _
"with the presentation name and its path. " & _
"Do you want to continue?", vbQuestion + vbYesNo, _
"Warning!")
' If no is selected in the dialog box, quit the macro.
If FeedBack = vbNo Then
End
End If
PathAndName = LCase(ActivePresentation.Name)
With ActivePresentation.HandoutMaster.HeadersFooters
With .Footer
.Text = PathAndName
End With
End With
End Sub
Sub Auto_Close()
Dim oControl As CommandBarControl
Dim ToolsMenu As CommandBars
' Get an object reference to a command bar.
Set ToolsMenu = Application.CommandBars
' Loop through the commands on the tools menu.
For Each oControl In ToolsMenu("Tools").Controls
' Check to see whether the comand exists.
If oControl.Caption = "Add Filename to Handout Footer"
Then
' Check to see whether action setting is set to
ChangeView.
If oControl.OnAction = "UpdatePath" Then
' Remove the command from the menu.
oControl.Delete
End If
End If
Next oControl
End Sub
Pardon me if this is an unbelievably mangled problem, where it
shouldn't be. I have Excel and Word VBA experience, but none in PP.
I have a macro (UpdatePath, below) that works, that I want to run any
time I open a ppt file. Actually, it's a little more complicated. I
found info online that suggested I need an auto_open and an auto_close
procedure around it, so I added that and tweaked it. I saved the code
as an add-in (*.ppam). I loaded the add-in. It doesn't fire.
Can someone please point me towards how to fix this, or else point me
to a How-To that works? THANKS. The code:
Sub Autpen()
Dim NewControl As CommandBarControl
' Store an object reference to a command bar.
Dim ToolsMenu As CommandBars
' Figure out where to place the menu choice.
Set ToolsMenu = Application.CommandBars
' Create the menu choice. The choice is created in the first
' position in the Tools menu.
Set NewControl = ToolsMenu("Tools").Controls.Add _
(Type:=msoControlButton, _
Before:=1)
' Name the command.
NewControl.Caption = "Add Filename to Handout Footer"
' Connect the menu choice to your macro. The OnAction property
' should be set to the name of your macro.
NewControl.OnAction = "UpdatePath"
End Sub
Sub UpdatePath()
' Macro to add the path and file name to each slide's footer.
Dim PathAndName As String
Dim FeedBack As Integer
' Place a message box warning prior to replacing footers.
FeedBack = MsgBox( _
"This Macro replaces any existing text that appears " & _
"within your current footers " & Chr(13) & _
"with the presentation name and its path. " & _
"Do you want to continue?", vbQuestion + vbYesNo, _
"Warning!")
' If no is selected in the dialog box, quit the macro.
If FeedBack = vbNo Then
End
End If
PathAndName = LCase(ActivePresentation.Name)
With ActivePresentation.HandoutMaster.HeadersFooters
With .Footer
.Text = PathAndName
End With
End With
End Sub
Sub Auto_Close()
Dim oControl As CommandBarControl
Dim ToolsMenu As CommandBars
' Get an object reference to a command bar.
Set ToolsMenu = Application.CommandBars
' Loop through the commands on the tools menu.
For Each oControl In ToolsMenu("Tools").Controls
' Check to see whether the comand exists.
If oControl.Caption = "Add Filename to Handout Footer"
Then
' Check to see whether action setting is set to
ChangeView.
If oControl.OnAction = "UpdatePath" Then
' Remove the command from the menu.
oControl.Delete
End If
End If
Next oControl
End Sub