G
Geoff Cox
oSh.ActionSettings(ppMouseClick).Hyperlink.Delete
Steve,
Excellent! Thanks a million!
There's an old Yorkshire saying, "Everything comes to them as waits"!
I was thinking of deleting the button and recreating it but held off -
didn't want to throw too many questionstoo quickly at you both!
Just thought of another old saying - which sometimes applies to me I
think - the man who got on a horse and rode off in all directions!
I have added the working code below.
If I had wanted to recreate the button after deleting it how would
that be done?
If oSh.AutoShapeType = 130 Then
oSh.delete
then what?
Cheers
Geoff
PS still no book around specifically on VBA for PowerPoint? I do have
David M's book but would love to see one just on the coding itself -
there seem to be lots on Excel and Access but not PPT...
Sub search_for_button_sr()
'code finds all ppt files in c:\test\ and any sub-folders
Set fs = Application.FileSearch
With fs
.LookIn = "C:\test\"
.SearchSubFolders = True
.FileName = "*.ppt"
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
'Debug.Print .FoundFiles(i)
check_for_button (.FoundFiles(i))
Next i
Else
MsgBox "There were no files found."
End If
End With
End Sub
Sub check_for_button(strMyFile As String)
'sub finds any type 1 / type 130 action buttons (ForwardOrNext)
'and changes them to 132 (End Show)
'also deletes the current hyperlink and changes it
'it to End Show
Dim oPresentation As Presentation
Set oPresentation = Presentations.Open(strMyFile)
With oPresentation
Dim oSl As Slide
For Each oSl In ActivePresentation.Slides
'For Each oSl In oPresentation
ActiveWindow.View.GotoSlide (oSl.SlideIndex)
Dim oSh As shape
Dim oHl As Hyperlink
For Each oSh In oSl.Shapes
If oSh.Type = 1 Then
If oSh.AutoShapeType = 130 Then
If oSh.TextFrame.TextRange.Text <> "Classroom notes" _
Then
oSh.ActionSettings(ppMouseClick).Hyperlink.Delete
oSh.ActionSettings(ppMouseClick).Action = _
ppActionEndShow
oSh.AutoShapeType = 132
'oSh.Select
'MsgBox "end button found in slide " & oSl.SlideIndex
'MsgBox _
oSh.ActionSettings(ppMouseClick).Hyperlink.Address
End If
End If
End If
Next oSh
Next oSl
oPresentation.Save
oPresentation.Close
End With
Set oSh = Nothing
Set oPresentation = Nothing
End Sub