VBA - make view active?

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
 
S

Shyam Pillai

That's really weird and I cannot reproduce it. I would've thought that the
action setting was applied to the text. Since the action setting applied to
text and shape can be distinct, that would explain why end show was failing.


--
Regards,
Shyam Pillai

Animation Carbon
http://www.animationcarbon.com
 
S

Steve Rindsberg

That's really weird and I cannot reproduce it. I would've thought that the
action setting was applied to the text. Since the action setting applied to
text and shape can be distinct, that would explain why end show was failing.

That's a very good question, so I just pulled up the files again to verify.

There's no action setting or hyperlink applied to the text; only to the action
button itself.

I can't reproduce it here either other than using Geoff's file.

With Geoff's permission, I'll send a copy along, if you like.
 
S

Steve Rindsberg

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?

Simplest is to start by recording a macro as you add the button and set action
settings.

Then modify it. It'll look like

ActiveWindow.Selection.SlideRange.Shapes.AddShape(yada,yada,,,).Select

You'd change that to:

Set oSh = oSl.Shapes.AddShape(all,the,same,yada,yada)

Then modify the properties of oSh as needed
 
G

Geoff Cox

Simplest is to start by recording a macro as you add the button and set action
settings.

Then modify it. It'll look like

ActiveWindow.Selection.SlideRange.Shapes.AddShape(yada,yada,,,).Select
You'd change that to:

Set oSh = oSl.Shapes.AddShape(all,the,same,yada,yada)

Then modify the properties of oSh as needed

Steve,

had almost forgotten about the recording facility!

Thanks

Geoff
 
G

Geoff Cox

That's a very good question, so I just pulled up the files again to verify.

There's no action setting or hyperlink applied to the text; only to the action
button itself.

I can't reproduce it here either other than using Geoff's file.

With Geoff's permission, I'll send a copy along, if you like.

Steve,

No problem at all - I was just about offer to do that myself!

Cheers

Geoff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

finding oHl.Address for an action button? 2
VBA question 11
code not working - why? 10
VBA error? 2
vba logic? 13
VBA removes other animation?! 6
how get the Hammer sound? 1
Help with VBA 4

Top