Results 1 to 6 of 6

Thread: Solved: How do I replace text in a table?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,096
    Location
    Hi (again) Paul
    I think you'll find only the first occurance in a cell is replaced? If the word is repeated the other occurrances won't change.

    May not matter in your situation but I think you could use oTemp like this:

    [vba]Private Sub Table_Find_Replace(T As Table, BeforeText As String, Optional AfterText As String = vbNullString, _
    Optional WholeWords As MsoTriState = False, Optional MatchCase As MsoTriState = False)

    Dim iRow As Long, iCol As Long
    Dim oText As TextRange, oTemp As TextRange

    With T
    For iRow = 1 To .Rows.Count
    For iCol = 1 To .Columns.Count
    Set oText = .Cell(iRow, iCol).Shape.TextFrame.TextRange
    Do
    Set oTemp = oText.Replace(BeforeText, AfterText, , WholeWords, MatchCase)
    Loop While Not oTemp Is Nothing
    Next iCol
    Next iRow
    End With
    End Sub[/vba]
    Last edited by John Wilson; 04-15-2012 at 02:23 AM.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

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