Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 06-25-2017, 06:51 AM
leaning leaning is offline "If it's a red bolded space, highlight it" macro? Windows 7 64bit "If it's a red bolded space, highlight it" macro? Office 2010 64bit
Novice
"If it's a red bolded space, highlight it" macro?
 
Join Date: Jan 2011
Posts: 19
leaning is on a distinguished road
Question

I tried this code to find all the red-bold-spaces and replace with them with @'s so I can then go back through, search for @, and delete them one by one. It will put @'s between words instead of just looking for the spaces before and after the phrases, but it's better than nothing. But it keeps giving me a "Specified value out of range" error.
I'm stumped.

Code:
Sub FindReplaceAll()
'PURPOSE: Find & Replace text/values throughout entire PowerPoint presentation
'SOURCE: www.TheSpreadsheetGuru.com/the-code-vault

Dim sld As Slide
Dim shp As Shape
Dim ShpTxt As TextRange
Dim TmpTxt As TextRange
Dim FindWord As Variant
Dim ReplaceWord As Variant

FindWord = " "
ReplaceWord = "@"

'Loop through each slide in Presentation
  For Each sld In ActivePresentation.Slides
    
    For Each shp In sld.Shapes
    If shp.HasTextFrame Then
      'Store shape text into a variable
        Set ShpTxt = shp.TextFrame.TextRange
      
      'Ensure There is Text To Search Through
        If ShpTxt <> "" Then
  If ShpTxt.Font.Bold = msoTrue And oTxtRng.Font.Color = vbRed Then
          'Store text into a variable
            Set ShpTxt = shp.TextFrame.TextRange
          
          'Find First Instance of "Find" word (if exists)
            Set TmpTxt = ShpTxt.Replace( _
             FindWhat:=FindWord, _
             Replacewhat:=ReplaceWord, _
             WholeWords:=True)
      
          'Find Any Additional instances of "Find" word (if exists)
            Do While Not TmpTxt Is Nothing
              Set ShpTxt = ShpTxt.Characters(TmpTxt.Start + TmpTxt.Length, ShpTxt.Length)
              
              Set TmpTxt = ShpTxt.Replace( _
               FindWhat:=FindWord, _
               Replacewhat:=ReplaceWord, _
               WholeWords:=True)
            Loop
          End If
        End If
        End If
    Next shp
      
  Next sld
MsgBox "Done"
End Sub
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
&quot;If it's a red bolded space, highlight it&quot; macro? how to highlight all "indexed" sentences using find and replace? smallxyz Word 2 02-06-2016 02:54 AM
&quot;If it's a red bolded space, highlight it&quot; macro? space bar "deletes" as it "spaces" S.R.C. Word 2 04-19-2015 05:56 AM
remove repeated words with " macro " or " wild cards " in texts with parentheses and commas jocke321 Word VBA 2 12-10-2014 11:27 AM
Wierd symbols inplace of "space", "indentation" etc aka.bhagvanji Word 5 02-16-2012 11:50 AM
&quot;If it's a red bolded space, highlight it&quot; macro? The heading doesn't "obey" the "before" space! why? Jamal NUMAN Word 1 07-06-2011 04:25 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:03 PM.


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