Results 1 to 16 of 16

Conditional replace accented characters with non-accented ones

Threaded View

  1. #8
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,851

    Re: Conditional replace accented characters with non-accented ones

    Try:
    Sub Demo()
    Application.ScreenUpdating = False
    Dim StrFnd As String, Rng As Range, i As Long, j As Long
    StrFnd = "03AC 03B1 03AD 03B5 03AE 03B7 0390 03B9 03CA 03B9 03AF 03B9 03CC 03BF 03CD 03C5 03B0 03C5 03CE 03C9"
    For i = 0 To UBound(Split(StrFnd, " ")) Step 2
      With ActiveDocument.Range
        With .Find
          .ClearFormatting
          .Replacement.ClearFormatting
          .Replacement.Text = ""
          .Forward = True
          .Wrap = wdFindStop
          .MatchWildcards = True
          .Text = "<" & ChrW("&H" & Split(StrFnd, " ")(i)) & "*>"
          .Execute
        End With
        Do While .Find.Found = True
          Set Rng = .Duplicate
          With .Duplicate
            .Start = .Start + 1
            For j = 0 To UBound(Split(StrFnd, " ")) Step 2
              If InStr(.Text, ChrW("&H" & Split(StrFnd, " ")(j))) > 0 Then
                Rng.Characters.First.Text = ChrW("&H" & Split(StrFnd, " ")(i + 1))
                Exit For
              End If
            Next
          End With
          .Collapse wdCollapseEnd
          .Find.Execute
        Loop
      End With
    Next
    With ActiveDocument.Range
      With .Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .MatchWildcards = True
        .Text = "<" & ChrW("&H03B5") & ChrW("&H03CD") & "*>"
        .Execute
      End With
      Do While .Find.Found = True
        Set Rng = .Duplicate
        Rng.Start = Rng.Start + 1
        With .Duplicate
          .Start = .Start + 2
          For j = 0 To UBound(Split(StrFnd, " ")) Step 2
            If InStr(.Text, ChrW("&H" & Split(StrFnd, " ")(j))) > 0 Then
              Rng.Characters.First.Text = ChrW("&H03C5")
              Exit For
            End If
          Next
        End With
        .Collapse wdCollapseEnd
        .Find.Execute
      Loop
    End With
    Application.ScreenUpdating = True
    End Sub
    Last edited by macropod; 04-20-2014 at 08:28 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Replace/remove accented characters
    By guest2013 in forum Excel General
    Replies: 3
    Last Post: 08-19-2013, 01:46 AM
  2. [SOLVED] find and replace to not replace characters found as wildcards
    By sabutler4 in forum Excel General
    Replies: 4
    Last Post: 07-03-2013, 06:48 PM
  3. Macro to replace European characters with non "special" English characters?
    By johanna0507 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2012, 09:13 AM
  4. Sort on accented (French) characters
    By greek in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-30-2011, 06:43 AM
  5. How do I replace just a few characters?
    By Tomsriv in forum Excel General
    Replies: 3
    Last Post: 08-14-2006, 07:09 PM

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