Results 1 to 12 of 12
  1. #1
    Lounger
    Join Date
    Jul 2008
    Posts
    36
    Thanks
    4
    Thanked 0 Times in 0 Posts

    How to find only words with diacritical symbols?

    Hi!
    In an Arabic text, how can I find only words with diacritic symbols?
    I put a screen image below. In the "arabicpage.png" file red colored words should find only. A small example page (arabicpage.docx) also added. In the real document words aren't colored. Thanks.

    arabic page.PNG
    Attached Files Attached Files

  2. #2
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,048
    Thanks
    124
    Thanked 119 Times in 116 Posts
    The only way I can imagine is a macro that searches from the insertion point to the next letter with a diacritical symbol and then selects the entire word. What you are really asking for here is to find words that contain certain letters and then select the word. I can't conceive of any macro that will search for the next diacritical symbol because it really is the symbol of a letter with a diacritical mark, not a diacritical mark.

    Searching for symbols, itself, is not necessarily straightforward. See http://word.mvps.org/faqs/general/UsingWildcards.htm for more thoughts.
    Charles Kyle Kenyon
    Madison, Wisconsin

  3. #3
    Lounger
    Join Date
    Jul 2008
    Posts
    36
    Thanks
    4
    Thanked 0 Times in 0 Posts
    How can I write such macro?
    What is the ascii code of symbols for the letters in Arabic?

  4. #4
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,048
    Thanks
    124
    Thanked 119 Times in 116 Posts
    Sorry, I don't know.

    You may be able to copy the letter you are looking for and paste it into Word's Find dialog. It is possible that these characters are simply treated as letters in the Arabic version of Word.I don't know.

    I would start by recording a macro to look for one particular letter and select the word containing it. I would then try one for the ascii code (which I do not know). I would then examine the vba to get an idea of where to go.

    For me, this would be an all-day project. For a more experienced Word programmer probably a couple of hours. I don't think it will be simple. For the ascii try Google "ascii Arabic" and see what you get.
    Last edited by Charles Kenyon; 2011-09-09 at 17:17.
    Charles Kyle Kenyon
    Madison, Wisconsin

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    There also is a way to search for Unicode characters by number. Something along the lines of .Find.Text = ChrW(5678) where the 5678 is the unicode value.

  6. #6
    Lounger
    Join Date
    Jul 2008
    Posts
    36
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I found some knowledge.
    There are 8 Unicode characters by number. If I can find any of them, then I will expand the word.
    ChrW(1611), ChrW(1612), ChrW(1613), ChrW(1614), ChrW(1615), ChrW(1616), ChrW(1617), ChrW(1618)
    I wrote a macro, but it didn't work.
    Or any other solutions...

    Code:
    Sub FindAnySymbols()
        Call findnembol(FindChar:=ChrW(1611) Or ChrW(1612) Or ChrW(1613) Or ChrW(1614) Or ChrW(1615) Or ChrW(1616) Or ChrW(1617) or ChrW(1618), FindFont:="Symbol")
    End Sub
    
    Sub findnembol(FindChar As String, FindFont As String)
    Dim FoundFont As String, OriginalRange As Range, strFound As Boolean
    Application.ScreenUpdating = False
    Set OriginalRange = Selection.Range
    strFound = False
    With Selection.Find
        .ClearFormatting
        .Text = FindChar
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.Extend
    End Sub
    Last edited by jscher2000; 2011-09-10 at 13:34. Reason: Changed [quote] tags to [code] tags.

  7. #7
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,048
    Thanks
    124
    Thanked 119 Times in 116 Posts
    I'm in way over my head here.

    Here is some code that I've been working on to find one of your letters:

    Code:
    Sub GetCharNoAndFont()
    ' figure out ascii code and font for character - to use, select character and run - view immediate window for resurt
    ' use this result in next macro
    
       With Dialogs(wdDialogInsertSymbol)
             Debug.Print "Font: " & .Font
             Debug.Print "Char number " & .CharNum
       End With
    
    End Sub
    
    Sub Find1614Symbols()
        'Call the main "FindSymbols" macro (below),
        'and tell it what character code  and font to search for
    'this uses results from previous macro
           Call FindSymbols(FindChar:=ChrW(1614), FindFont:="(normal text)")
    End Sub
    
    Sub FindSymbols(FindChar As String, FindFont As String)
    
    Dim FoundFont As String, OriginalRange As Range, strFound As Boolean
    Application.ScreenUpdating = False
    
    'set range to return to in case symbol not found
    Set OriginalRange = Selection.Range
    
    strFound = False
    With Selection.Find
        .ClearFormatting
        .Text = FindChar
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
       
        Do While .Execute    'Keep going until nothing found
            If Dialogs(wdDialogInsertSymbol).Font = FindFont Then
               'If the correct character was found, exit loop
               strFound = True
               Exit Do
            Else
               'Otherwise search again
               Selection.Collapse wdCollapseEnd
            End If
        Loop
    
        If Not strFound Then
            'if nothing found, search from the beginning of the document
            ActiveDocument.Range(0, 0).Select
            Do While .Execute
                If Dialogs(wdDialogInsertSymbol).Font = FindFont Then
                    strFound = True
                    Exit Do
                Else
                    Selection.Collapse wdCollapseEnd
                End If
            Loop
        End If
      
    End With
    
    If Not strFound Then
        OriginalRange.Select
    End If
    
    Set OriginalRange = Nothing
    Application.ScreenUpdating = True
    
    End Sub
    -----
    This was based on Dave Rado's page at: http://word.mvps.org/faqs/MacrosVBA/...aceSymbols.htm

    Hope this gives you a start, anyway.

    Edit: Last edited by Charles Kenyon; 2011-09-10 at 07:52. Reason: add comments to code
    Last edited by jscher2000; 2011-09-10 at 13:35. Reason: Added [code][/code] around code to preserve formatting.
    Charles Kyle Kenyon
    Madison, Wisconsin

  8. #8
    Lounger
    Join Date
    Jul 2008
    Posts
    36
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Hi!
    I was a bit confused. But I'll try to understand. Many thanks.

  9. #9
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,048
    Thanks
    124
    Thanked 119 Times in 116 Posts
    I hope that if you find a solution you will share it here. It is an interesting problem.
    Charles Kyle Kenyon
    Madison, Wisconsin

  10. #10
    Lounger
    Join Date
    Jul 2008
    Posts
    36
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I found a simple solution.

    1. First turn Wildcards on in the Find dialog.
    2. Click More
    3. Click special
    4. Select Square brackets [-] it's important to select with - among them.
    5. Copy this group of characters ًٌٍَُِّْٕٖٔٓ You can add other characters typing ALT+1611 to ALT+1622 (The generic term for such diacritical signs is ḥarakāt).
    6. Select - sign and paste
    7. You'll have a view like this [ًٌٍَُِّْٕٖٔٓ] here there are 14 characters but they do not appear !!!
    8. Click find. You can find any of them.
    9. Close Find dialog.
    10. Run that kind of macro or any other your own.

    Sub FindInFindDialog()
    Dim i As Integer
    For i = 1 To 300
    Selection.Find.Execute
    Selection.Expand unit:=wdWord
    Selection.Font.Color = wdColorRed
    Next
    End Sub
    This example changes the color of the selected words (words by words, so phrases) to red.

  11. #11
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts
    The following code will color red all words that contain the letter "a". You could modify this to look for the unicode characters instead of Chr$(97).

    Sub FindWordsWithCharacter()
    Dim w
    For Each w In ActiveDocument.Range.Words
    If InStr(w.Text, Chr$(97)) Then ' words with the letter "a"
    w.Font.Color = wdColorRed
    End If
    Next
    End Sub

  12. #12
    Lounger
    Join Date
    Jul 2008
    Posts
    36
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Hi!
    This is much more useful for diacritics. Thank you very much.

    Sub FindWordsWithCharacter()
    Dim w
    For Each w In ActiveDocument.Range.Words
    If InStr(w.Text, ChrW(1611)) Or InStr(w.Text, ChrW(1612)) Or InStr(w.Text, ChrW(1613)) Or InStr(w.Text, ChrW(1614)) _
    Or InStr(w.Text, ChrW(1615)) Or InStr(w.Text, ChrW(1616)) Or InStr(w.Text, ChrW(1618)) _
    Or InStr(w.Text, ChrW(1619)) Or InStr(w.Text, ChrW(1622)) Then ' words with diacritics
    w.Font.Color = wdColorRed
    End If
    Next
    End Sub

Posting Permissions

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