I have spent most of the day trying to figure this out and finally gave up. I found code (below) that will update a text box in ppt with the file path and name... i now would like to have this automatically run before i save the file (i.e. i make change hit save and it updates the file path). I found a couple tutorials but i dont know enough about VBA to make it work
Tutorials I am trying to piece together:
MSDN1
MSDN2
MSDN3
I have this in Class 1:
I have this in Module1:
Tutorials I am trying to piece together:
MSDN1
MSDN2
MSDN3
I have this in Class 1:
Code:
Public WithEvents App As PowerPoint.Application
I have this in Module1:
Code:
Dim X As New Eventclassmodule
Sub initializeapp()
Set X.App = PowerPoint.Application
End Sub
Sub App_PresentationBeforeSave(ByVal Pres As Presentation)
' Adds a text box with date and filename to each slide
' You must first save the presentation at least once before using this
Dim oSl As Slide
Dim oSh As Shape
On Error GoTo ErrorHandler
For Each oSl In ActivePresentation.Slides
' do we already have a filename/date text box? If do, use it:
On Error Resume Next
Set oSh = oSl.Shapes("FilenameAndDate")
On Error GoTo ErrorHandler
If oSh Is Nothing Then ' no text box there already, create one
' change the position and formatting to suit your needs:
Set oSh = oSl.Shapes.AddTextbox(msoTextOrientationHorizontal, 0, 520, 720, 28.875)
With oSh
.Name = "FilenameAndDate"
.TextFrame.WordWrap = msoTrue
With .TextFrame.TextRange.ParagraphFormat
.LineRuleWithin = msoTrue
.SpaceWithin = 1
.LineRuleBefore = msoTrue
.SpaceBefore = 0.5
.LineRuleAfter = msoTrue
.SpaceAfter = 0
End With
With .TextFrame.TextRange.Font
.NameAscii = "Calibri"
.Size = 11
.Bold = msoFalse
.Italic = msoFalse
.Underline = msoFalse
.Shadow = msoFalse
.Emboss = msoFalse
.BaselineOffset = 0
.AutoRotateNumbers = msoFalse
.Color.SchemeColor = ppForeground
End With
End With ' shape
End If ' osh is nothing
' now we know there's a shape by the correct name so
Set oSh = oSl.Shapes("FilenameAndDate")
With oSh.TextFrame.TextRange
'.Text = ActivePresentation.FullName & vbTab & Format(Now, "mmmm dd, yyyy")
.Text = ActivePresentation.FullName
End With
Set oSh = Nothing
Next ' slide
NormalExit:
Exit Sub
ErrorHandler:
MsgBox ("There was a problem:" _
& vbCrLf _
& Err.Description)
Resume NormalExit
End Sub