|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How to change the transparency of a selected text with VBA for PowerPoint
I have text in a text box. I need to know how to change the transparency of each letter (individually) with VBA for PowerPoint.
I know that by changing the transparency of a shape I can do this: shape.Fill.Transparency = transparency, where transparency is a value between 0.0 and 1.0. how do I change the transparency of a letter (eg randomly with RND)? |
#2
|
|||
|
|||
This sort of thing maybe - you should add some error checking.
Code:
Sub trans_text() Dim oshp As Shape Dim otxr2 As TextRange2 Dim L As Long Set oshp = ActiveWindow.Selection.ShapeRange(1) If oshp.HasTextFrame Then Set otxr2 = oshp.TextFrame2.TextRange For L = 1 To otxr2.Characters.Count otxr2.Characters(L).Font.Fill.Transparency = Rnd * 1 Next L End If End Sub |
#3
|
|||
|
|||
Thank you JohnWilson for your post.
This is my code, Sub ChangeTextTransparency() Dim Slide As Slide Dim shape As shape Dim paragraph As TextRange Dim letter As TextRange Dim slidenumber As Integer slidenumber = 8 Dim textBoxIndex As Long textBoxIndex = 1 Set Slide = ActivePresentation.Slides(slidenumber) If textBoxIndex <= Slide.Shapes.Count And textBoxIndex > 0 Then Set shape = Slide.Shapes(textBoxIndex) If shape.HasTextFrame Then For Each paragraph In shape.TextFrame.TextRange.Paragraphs For Each letter In paragraph.Characters letter.Paragraphs.Characters.Select ActiveWindow.Selection.TextRange2.Characters.Font. Fill.transparency = Rnd Next letter Next paragraph End If End If End Sub My problem is when I start the presentation. As you know to use ActiveWindow.Selection... you should have something selected. I have selected each letter with letter.Paragraphs.Characters.Select and then ActiveWindow.Selection.TextRange2.Characters.Font. Fill.transparency = Rnd. I put this code in a Slide8 Objet with Private Sub App_SlideShowNextSlide(ByVal Wn As SlideShowWindow) but it doesn't work in Presentation mode. When I am in Presentation mode and I am on slide 8 (where I need the code to be executed) Does the Selection Objet work in Presentation mode? |
#4
|
|||
|
|||
You cannot select anything in Presentation Mode
Try this code and give the SHAPE with the text an action of run Macro then click on the shape in show mode. Code:
Sub trans_text(oshp As Shape) Dim otxr2 As TextRange2 Dim L As Long If oshp.HasTextFrame Then Set otxr2 = oshp.TextFrame2.TextRange For L = 1 To otxr2.Characters.Count otxr2.Characters(L).Font.Fill.Transparency = Rnd * 1 Next L End If End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Change background of selected text | ultrarunner2020 | Word | 5 | 03-10-2023 02:59 PM |
Powerpoint-2019 Text in selected theme remains in All Caps even when small caps option is selected | Tanasha4 | PowerPoint | 2 | 04-06-2019 07:53 PM |
How to change color indicating selected text | daylee | Word | 1 | 03-27-2019 01:31 PM |
Please help. I want to change the text of a cell when another is selected | frankzelnik | Excel | 5 | 06-19-2018 01:34 PM |
Margin change for selected text in Word 7 | Richtriebe | Word | 4 | 03-14-2016 11:57 AM |