Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-09-2023, 10:02 AM
JavierA JavierA is offline How to change the transparency of a selected text with VBA for PowerPoint Windows 10 How to change the transparency of a selected text with VBA for PowerPoint Office 2021
Novice
How to change the transparency of a selected text with VBA for PowerPoint
 
Join Date: Aug 2023
Posts: 2
JavierA is on a distinguished road
Post 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)?
Reply With Quote
  #2  
Old 08-10-2023, 12:16 PM
JohnWilson JohnWilson is offline How to change the transparency of a selected text with VBA for PowerPoint Windows 10 How to change the transparency of a selected text with VBA for PowerPoint Office 2019
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

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
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #3  
Old 08-11-2023, 02:05 AM
JavierA JavierA is offline How to change the transparency of a selected text with VBA for PowerPoint Windows 10 How to change the transparency of a selected text with VBA for PowerPoint Office 2021
Novice
How to change the transparency of a selected text with VBA for PowerPoint
 
Join Date: Aug 2023
Posts: 2
JavierA is on a distinguished road
Default

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?
Reply With Quote
  #4  
Old 08-14-2023, 08:48 AM
JohnWilson JohnWilson is offline How to change the transparency of a selected text with VBA for PowerPoint Windows 10 How to change the transparency of a selected text with VBA for PowerPoint Office 2019
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

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
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
Reply



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
How to change the transparency of a selected text with VBA for PowerPoint Margin change for selected text in Word 7 Richtriebe Word 4 03-14-2016 11:57 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:00 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft