PDA

View Full Version : How to select a specific Textbox in a powerpoint slide with user selection



ayrus
03-12-2024, 06:40 AM
Hello Everyone,

Is it possible to allow user to select a specific textbox using VBA and get word-count of that textbox?

thanks

Aussiebear
03-12-2024, 01:46 PM
Maybe this will give you some ideas.


Option Explicit

Sub CountSomeWords()
' Example of how to use WordsOnSlide
Dim oSl As Slide
Dim lWordCount As Long
For Each oSl In ActivePresentation.Slides
lWordCount = lWordCount + WordsOnSlide(oSl)
Next
MsgBox lWordCount
End Sub

Function WordsOnSlide(oSl As Slide) As Long
' Gives APPROXIMATE word count of the words in
' text boxes and normal shapes on a slide
' Does not count shapes in groups, text in charts
' smart art, graphics, etc.
Dim oSh As Shape
Dim lCount As Long
For Each oSh In oSl.Shapes
If oSh.HasTextFrame Then
If oSh.TextFrame.HasText Then
lCount = lCount + oSh.TextFrame.TextRange.Words.Count
End If
End If
Next
WordsOnSlide = lCount
End Function

Faut1960
07-14-2024, 11:59 PM
geometry dash meltdown (https://geometrydash-meltdown.com/)

Maybe this will give you some ideas.


Option Explicit

Sub CountSomeWords()
' Example of how to use WordsOnSlide
Dim oSl As Slide
Dim lWordCount As Long
For Each oSl In ActivePresentation.Slides
lWordCount = lWordCount + WordsOnSlide(oSl)
Next
MsgBox lWordCount
End Sub

Function WordsOnSlide(oSl As Slide) As Long
' Gives APPROXIMATE word count of the words in
' text boxes and normal shapes on a slide
' Does not count shapes in groups, text in charts
' smart art, graphics, etc.
Dim oSh As Shape
Dim lCount As Long
For Each oSh In oSl.Shapes
If oSh.HasTextFrame Then
If oSh.TextFrame.HasText Then
lCount = lCount + oSh.TextFrame.TextRange.Words.Count
End If
End If
Next
WordsOnSlide = lCount
End Function




Thanks. I know what I have to do.