Remove or Hide PowerPoint Controls on All Slides

ppt3If you customize PowerPoint with controls (button, text boxes, labels, etc.) you may want to delete or hide these to create a clean version of your presentation. Below is a script you can use hide all of the controls (or you can filter). My example uses PowerPoint 2010 but should apply to most recent versions:

 

1. Create a new module: ppt1

2. Paste the below text:

Public Sub HideControls()

'keep a count of how many items hidden - just fyi
Dim cntrlCount As Integer
    'loop through slides
    For Each sld In ActivePresentation.Slides
        'loop through slide shapes - includes button, text boxes, ole controls, etc
        For Each shp In sld.Shapes
        
        ''Filter here if you want - by name or type
        ' If InStr(shp.Name, "command") >= 1 Then
        ' If shp.Type = 3 Then
        
        'set hidden
        shp.Visible = False
        
        'if you wanted to delete*: shp.Delete
        
        cntrlCount = cntrlCount + 1
        
        Next
    
    Next

MsgBox cntrlCount & " items affected."

End Sub

3. Click Run (green play button) to run this code and hide your controls. ppt2

 

If you want to show or unhide your controls, change shp.Visible = False to shp.Visible = True

 

*Note: if you use shp.Delete, you won’t be able to recover your items.

Remove or Hide PowerPoint Controls on All Slides

The Classic: Cannot refer to an instance member of a class from within a shared method…

I am sure you’ve gotten this before:

Cannot refer to an instance member of a class from within a shared method

Well, instead of all the reasons why, I will just tell you one simple solution:

Pretend you’re doing this:

Public Shared Function getSomething() As Integer
   For Each tControl As Control In FlowLayoutPanel1.Controls    Next

End Function

It will ERROR.

Now Add the form name:

Public Shared Function getSomething() As Integer
   For Each tControl As Control In sampleForm.FlowLayoutPanel1.Controls   Next

End Function

And run again!

The Classic: Cannot refer to an instance member of a class from within a shared method…

Creating & Playing Playlist – VB.Net Windows Media Player Control

'create playlist
 Dim newPlayList As WMPLib.IWMPPlaylist = wmpControl.playlistCollection.newPlaylist("soundsToPlay")
 newPlayList.appendItem(wmpControl.newMedia("C:\Sample1.mp3"))
 newPlayList.appendItem(wmpControl.newMedia("C:\Sample2.mp3"))
'play the list
 wmpControl.Visible = False
 wmpControl.currentPlaylist = newPlayList
 wmpControl.stretchToFit = True
 wmpControl.Ctlcontrols.play()
Creating & Playing Playlist – VB.Net Windows Media Player Control