Share via

VBA to change media Audio Styles from Play in Background to No Style

Anonymous
2022-01-29T15:52:34+00:00

It seems I've performed a pretty extension search for this but can't find the right syntax. This would of course be perfectly fine doing this in a slide, but I have multiple slides and multiple presentation to fix. Using VBA, how can I toggle the No Style on in the Audion Styles grouping in the Playback tab?

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2022-01-29T19:37:25+00:00

In my code you would need to select each slide too.

Try this instead if you just want the media to play onclick

Sub StartAdvance()

Dim sld    As Slide 

Dim shp    As Shape 

Dim myTime As Long 

Dim eff    As Effect 

Dim L      As Long 

For Each sld In ActivePresentation.Slides 

    sld.Select 

    For Each shp In sld.Shapes 

        For L = 1 To sld.TimeLine.MainSequence.Count 

            Set eff = sld.TimeLine.MainSequence(L) 

            If eff.Shape.Type = msoMedia Then 

                If eff.Shape.MediaType = ppMediaTypeSound Then 

                    eff.Timing.TriggerType = msoAnimTriggerOnPageClick 

                    eff.EffectInformation.PlaySettings.LoopUntilStopped = False 

                    eff.EffectInformation.PlaySettings.StopAfterSlides = 1 

                End If 

            End If 

        Next L 

    Next shp 

Next sld 

End Sub

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

7 additional answers

Sort by: Most helpful
  1. Steve Rindsberg 99,161 Reputation points MVP Volunteer Moderator
    2022-01-29T17:22:35+00:00

    I don't have an answer for you, but you might be able to work this out by creating inserting two sounds, setting one to No Style, the other to Play In Background, then examining the AnimationSettings.PlaySettings properties of each shape.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2022-01-29T17:22:30+00:00

    It is really not clear what you are trying to do. The NoStyle setting is not really to do slide transition, A full explaination of what you need is a good idea.

    If you just want to click the button(s) try

    Sub StartAdvance()

    Dim sld As Slide

    Dim shp As Shape

    Dim myTime As Long

    Dim eff As Effect

    For Each sld In ActivePresentation.Slides

    For Each shp In sld.Shapes

    If shp.Type = msoMedia Then

    If shp.MediaType = ppMediaTypeSound Then

    shp.Select

    If CommandBars.GetPressedMso("NoAudioStyle") = False Then

    CommandBars.ExecuteMso ("NoAudioStyle")

    End If

    End If

    End If

    Next shp

    Next sld

    End Sub

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2022-01-29T17:10:23+00:00

    Hi John,

    Here is what I've tried, but it leaves the Start dropdown blank.

    Sub StartAdvance() 
    
        Dim sld As Slide 
    
        Dim shp As Shape 
    
        Dim myTime As Long 
    
        Dim eff As Effect 
    
        For Each sld In ActivePresentation.Slides 
    
            For Each shp In sld.Shapes 
    
                If shp.Type = msoMedia Then 
    
                    If shp.MediaType = ppMediaTypeSound Then 
    
                        With sld.SlideShowTransition 
    
                            shp.AnimationSettings.PlaySettings.PlayOnEntry = False 
    
                        End With 
    
                    End If 
    
                End If 
    
            Next shp 
    
        Next sld 
    
    End Sub
    

    Was this answer helpful?

    0 comments No comments
  4. John Korchok 232.4K Reputation points Volunteer Moderator
    2022-01-29T16:40:06+00:00

    Please post your code as far as you've gotten with this.

    Was this answer helpful?

    0 comments No comments