Remove shadow effect from text in powerpoint 2010 VBA - vba

I am trying to remove all the shadow effects from all the textframes in the any slides of the presentation via a macro .
The below macro is running well with powerpoint 2007 but not working with 2010.
Sub NoTextShadows()
Dim oSld As Slide
Dim oShp As Shape
For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.HasTextFrame Then
If oShp.TextFrame.HasText Then
oShp.TextFrame.TextRange.Font.Shadow = msoFalse
oShp.Shadow.Visible = msoFalse
End If
End If
Next oShp
Next oSld
End Sub
Please suggest any idea to workaround this. Thanks.

I made some tests and I found out that shadows in PowerPoint 2010 can appear for Text (for specific) and for shapes in general. It's strange that two shadows can be applied to the shape independently, but only one of them could be removed by Macro. Here is what I did to remove one layer of shadow :
oShp.Shadow.Size = 0
OShp.Shadow.Blur = 0
oShp.Shadow.Visible = msoFalse
Try adding these lines inside your main For Loop and see
For more information, Working with Properties of the ShadowFormat Class in Office 2010

Related

Add Border Color to all tables Powerpoint VBA

Trying to add a border color to all tables in Powerpoint and failing. I'm not very good at this.
Sub SetTableBorder()
Dim oShp As Shape
Dim oTbl As Table
Dim oSld As Slide
For Each oSld In ActivePresentation.Slides
For Each oShp In oSl.Shapes
If oShp.HasTable Then
With oShp.Table
.Borders(ppBorderTop).ForeColor.RGB = RGB(235,186,182)
.Borders(ppBorderBottom).ForeColor.RGB = RGB(235,186,182)
.Borders(ppBorderLeft).ForeColor.RGB = RGB(235,186,182)
.Borders(ppBorderRight).ForeColor.RGB = RGB(235,186,182)
End With
End If
Next oShp
Next oSld
End Sub
First, correct the typo: oSl.Shapes --> oSld.Shapes
Next, add Option Explicit above all the subs/functions in this (and ideally all other) module. That'll prevent this kind of thing from biting you.
Next, you want to work with the table's .Rows(1).Cells.Borders(ppBorderTop) and its various properties to set the top border,
Something like .Rows(.Rows.Count).Cells ... etc to set the bottom border for the table.
Then similarly, .Columns(1).Cells ... properties ... to set the left border.
And so on.

VBA PowerPoint Display and Hide Shapes

I have several PowerPoint slides with objects (arrows and rectangles) I like to display and hide. At the moment I just use
ActivePresentation.Slides("Slide100").Shapes("Rectangle 99").Visible = False or True
ActivePresentation.Slides("Slide100").Shapes("Straight Arrow Connector 118").Visible = False or True
Now it can be that one rectangle or arrow has to be deleted in that template. This leads to VBA errors when you run the macro because the rectangle or arrow couldn't be found. Is there any way to write a macro to check all the used rectangles and arrows and then hides or displays them all instead of using single variables?
I found something like this:
For Each sObject In ActivePresentation.Slides(2).Shapes
sObject.Visible = False
Next
But I just need to hide rectangles and arrows, nothing more.
Best regards
Peter
Take that loop as a starting point and apply some logic within it. There are two properties of the shape that could be useful, autoshapetype and name
Two examples below:
For Each shp In ActivePresentation.Slides(x).Shapes
If InStr(1, shp.Name, "Rectangle") > 0 Then
shp.Visible = False
End If
Next shp
or
For Each shp In ActivePresentation.Slides(x).Shapes
If shp.AutoShapeType = msoShapeRectangle Then
shp.Visible = False
End If
Next shp
This will hide all rectangle types and a subset of arrow types across all slides in the active presentation:
' PowerPoint VBA Macro
' Purpose : hide rectangles and shapes across slides
' Written by : Jamie Garroch of YOUpresent Ltd. http://youpresent.co.uk.
Sub HideRectanglesAndArrows()
Dim oSld As Slide
Dim oShp As Shape
For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.Type = msoAutoShape Then
Select Case oShp.AutoShapeType
' Basic Arrows (4)
Case msoShapeUpArrow, msoShapeDownArrow, msoShapeLeftArrow, msoShapeRightArrow
oShp.Visible = msoFalse
' Double Arrows (2)
Case msoShapeUpDownArrow, msoShapeLeftRightArrow
oShp.Visible = msoFalse
' Add other arrow types as required
'
' Basic Rectangles (1)
Case msoShapeRectangle
oShp.Visible = msoFalse
' Rounded Rectangles (4)
Case msoShapeRound1Rectangle, msoShapeRound2DiagRectangle, msoShapeRound2SameRectangle, msoShapeRoundedRectangle
oShp.Visible = msoFalse
' Snipped Rectangles (4)
Case msoShapeSnip1Rectangle, msoShapeSnip2DiagRectangle, msoShapeSnip2SameRectangle, msoShapeSnipRoundRectangle
oShp.Visible = msoFalse
End Select
End If
Next
Next
End Sub
You can then add logic to delete specific shapes using the .Name property or position properties (.Left, .Top) or size properties (.Width, .Height). If you want o be more elaborate (users can change the names of shapes) then you could add Tags to shapes to identify them in a way that the user cannot change and then write a procedure to check the .Tags property in your logic.

What are Shape.TextFrame and .TextRange in PowerPoing VBA?

I am looking for information to help me better understand ".TextFrame" and ".TextRange" objects in PowerPoing VBA. Can anybody help? I have reviewed the stuff on MSDN and am just continually disappointed with the documentation there.
Shapes are the basic building blocks for PPT slides, masters, layouts, notes pages; everything on them is a shape.
Some shapes (lines for example) can't contain text. Those that can contain text have a TextFrame. If a Shape.TextFrame contains text, then you can use Shape.TextFrame.TextRange to get access to (set/read) the properties of all of the text in the TextFrame. Other methods also return a .TextRange that may be some subset of the text within the .TextFrame.
Simple example:
Sub DoSomethingUseless()
Dim oSh as Shape
Dim oSl as Slide
For Each oSl in ActivePresentation.Slides
For Each oSh in oSl.Shapes
If oSh.HasTextFrame Then
If oSh.TextFrame.HasText Then
Debug.Print oSh.TextFrame.TextRange.Text
End If
End If
Next ' Shape
Next ' Slide
End Sub

Powerpoint global button

I think it's a simple question for anybody with some VBA skills oder PowerPoint-pro's:
I have a presentation like a quiz, and I like to offer three jokers like in WWTBAM.
So I created three buttons and i made the 50:50 button, that on click an animation starts so, that to wrong answers are hidden. So I now just want to, that if you clicked the joker-button on one slide, it have to be removed / disabled / crossed on ALL other following slides.
Is there anybody who can show me a simple snippet which will do that?
That would be really great.
Thanks!
This should get you going in the right direction:
Option Explicit
' The name of the shape(s) to search for
' (name shapes in the Selection Pane : Alt+F10 for PowerPoint 2010 and later)
Public Const ShapeName = "50/50"
' Purpose: Macro to HIDE all shapes on all slides that match the specified name
' Usage: Assign to any shape(s) on a slide via the Insert Tab / Action / Mouse Click / Run Macro
' Author: Jamie Garroch of YOUpresent Ltd. (http://youpresent.co.uk/)
Public Sub HideAll()
Dim oSld As Slide
Dim oShp As Shape
For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.Name = ShapeName Then oShp.Visible = msoFalse
Next
Next
End Sub
' Purpose: Macro to SHOW all shapes on all slides that match the specified name
' Usage: Assign to any shape(s) on a slide via the Insert Tab / Action / Mouse Click / Run Macro
' Author: Jamie Garroch of YOUpresent Ltd. (http://youpresent.co.uk/)
Public Sub ShowAll()
Dim oSld As Slide
Dim oShp As Shape
For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.Name = ShapeName Then oShp.Visible = msoTrue
Next
Next
End Sub

PowerPoint vba - For each shape in each Layout in MasterView

I'm trying to programatically change the language of each shape in each customlayout in a PowerPoint template and I can't figure out how to do this. I've done it before, but I can't find the macro anymore so I don't really know how I did it. I've been able to select each custom layout though. But I need to loop through each textbox in each layout and select the language as well. My problem is targetting each shape. How do I do this?
This is what I've got so far:
ActiveWindow.ViewType = ppViewSlideMaster
For Each oLayout In ActivePresentation.SlideMaster.CustomLayouts
oLayout.Select
Next
This basically loops through each layout. But I can't figure out how to select each placeholder? How do I do this?
Edit: Resolution is now:
For Each oLayout In ActivePresentation.SlideMaster.CustomLayouts
oLayout.Select
Dim oShape As Shape
For Each oShape In oLayout.Shapes
oShape.Select
Next
Next
Loop through oLayout.Shapes, or perhaps oLayout.Shapes.Placeholders.
Thanks you two. I needed a solution to updating an embedded Excel object on the master slide.
This lead me to the perfect solution
'loops through all shapes in slidemaster
Dim oShape As Shape
For Each oShape In ActivePresentation.SlideMaster.Shapes
oShape.Select
'checks for excel object (type=7)
If oShape.Type = msoEmbeddedOLEObject Then
oShape.OLEFormat.Activate
ActiveWindow.Selection.Unselect 'deactivates shape
End If
Next