d:\ documents \のような特定の場所にファイルを保存すると、ファイルパスがフッターに表示されます。ファイルパスではなく名前だけが表示されるコードが見つかりましたが、再度保存すると名前が更新されませんでした。保存時にフッタへのファイルパスを更新する
ここにコードがあります。
Sub AddTextBoxDateFilename() ' 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, 510, 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 = "Arial"
.Size = 18
.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
End With
Set oSh = Nothing
Next ' slide
NormalExit:
Exit Sub
ErrorHandler:
MsgBox ("There was a problem:" & vbCrLf & Err.Description)
Resume NormalExit
End Sub
PowerPoint [アプリケーションイベント](https://msdn.microsoft.com/en-us/library/)を使用する必要があります。 office/ff746876(v = office.14).aspx)。 [this](https://msdn.microsoft.com/en-us/library/office/ff746018(v = office.14).aspx)を必ずお読みください。 – PatricK