Results 1 to 8 of 8

Find and replace words in PowerPoint using a Excel VBA macro

Threaded View

  1. #1
    Registered User
    Join Date
    10-02-2018
    Location
    Amsterdam
    MS-Off Ver
    2016
    Posts
    5

    Find and replace words in PowerPoint using a Excel VBA macro

    Hi everybody,

    I hope there is someone who can help me with the following:
    My goal is to have an Excel macro where i can put words in Column A that have to be changed in my Powerpoint presentation into the words that are in Column B.

    Here is a PowerPoint macro that allready finds and replaces words in PowerPoint, but it's not connected to Excel:
    Sub Multi_FindReplace()
    
    Dim sld As Slide
    Dim shp As Shape
    Dim ShpTxt As TextRange
    Dim TmpTxt As TextRange
    Dim FindList As Variant
    Dim ReplaceList As Variant
    Dim x As Long
    
    FindList = Array("Canada", "United States", "Mexico")
    ReplaceList = Array("CAN", "USA", "MEX")
    
    'Loop through each slide in Presentation
      For Each sld In ActivePresentation.Slides
        
        For Each shp In sld.Shapes
          'Store shape text into a variable
            Set ShpTxt = shp.TextFrame.TextRange
          
          'Ensure There is Text To Search Through
            If ShpTxt <> "" Then
              For x = LBound(FindList) To UBound(FindList)
                
                'Store text into a variable
                  Set ShpTxt = shp.TextFrame.TextRange
                
                'Find First Instance of "Find" word (if exists)
                  Set TmpTxt = ShpTxt.Replace( _
                   FindWhat:=FindList(x), _
                   Replacewhat:=ReplaceList(x), _
                   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:=FindList(x), _
                     Replacewhat:=ReplaceList(x), _
                     WholeWords:=True)
                  Loop
                  
              Next x
              
            End If
            
        Next shp
          
      Next sld
    
    End Sub
    Last edited by Leith Ross; 10-02-2018 at 07:54 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] macro find and replace in a specific column specific words to an abreviation
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-19-2018, 06:05 AM
  2. Replies: 3
    Last Post: 11-25-2014, 06:08 AM
  3. excel macro to find and replace particular words in all excel files in a folder
    By genetist in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-14-2014, 08:59 PM
  4. Highlight certain words in Word document after running find-and-replace from Excel
    By EnterTheSerpent in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-22-2012, 02:27 PM
  5. Replies: 2
    Last Post: 10-11-2012, 01:52 PM
  6. Replies: 4
    Last Post: 04-27-2012, 06:38 AM
  7. Find & Replace Powerpoint Text from Excel
    By lt0218 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-10-2011, 07:56 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1