word - color replacement of all first characters

Copper Contributor

I have successfully replaced the first character in a doc(hebrew) to a diff color. Used a macro to accomplish this. The doc has hebrew vowels under or part of each letter.

I used a new macro to delete every letter that is black. This kept all letters that were initially changed to another color.

The issue is upon deletion of the black characters, I'm left with the colored characters, but with the hebrew vowels removed. How do I prevent it from happening.

30 Replies
I am not really sure how the document is laid out to be able to determine if there is any other way, but at the moment it appears that you would also need to color the vowels as well.
If you can provide more information, or upload a copy of the document, it might be possible to come up with another way.
the vowels are colored. When the macro colored the first character of each word, it kept the vowels with the changed color.
How would I upload a document

@ggre1335 Click on the Open full text editor link

 

Doug_Robbins_Word_MVP_0-1656032733136.png

 

and you will see

Doug_Robbins_Word_MVP_1-1656032765912.png

 

 

tried to drag a docx file. message said not supported

@ggre1335 Sorry, but not knowing Hebrew, I am not able to distinguish the vowels from anything else in the document.

This is what I see when I open the document

Doug_Robbins_Word_MVP_0-1656224835531.png

 

 

It doesn't make a difference if it's in hebrew. I need to get get rid of the black characters. This will keep the green letters. The vowels under the letters disappear. If you do a find/replace based on color, it will get rid of the black and keep the green without the vowels Why?

@ggre1335 Using the Find and Replace shown below, you will get

 

Doug_Robbins_Word_MVP_0-1656249276389.png

 

I tried. Please walk me thru step by step

@ggre1335 

  1. Access the Find and Replace Dialog and click on the "More >>" button

    Doug_Robbins_Word_MVP_0-1656272837078.png

  2. Put the selection in the Find what: control and then click on the Format drop down and then on Font and in the Find Font dialog, select "Automatic" from the Font color dropdown and click on OK to close the Find Font dialog.

    Doug_Robbins_Word_MVP_1-1656273012458.png

     

  3. Put the selection in the Replace with control and click on the Format dropdown and then on Font, and in the Replace Font dialog, select White, Background 1 and click on OK to close the Replace Font dialog

    Doug_Robbins_Word_MVP_2-1656273267049.png

     

  4. In the Find and Replace dialog, you should then see the Formats that I have highlighted in yellow in the following screen shot and when you click on Replace all, you will get:

    Doug_Robbins_Word_MVP_3-1656273573934.png

     

Problem. I need to have all the remaining letters connected as a long string. My macro which follows deleted all the black with the remaining letters run-on without the vowlels

here's the macro

 

Sub DeleteBlackLettersInWords()
Dim objWord As Range
Dim i As Integer

For Each objWord In ActiveDocument.Words

' Delete black characters in every word.
For i = objWord.Characters.Count To 1 Step -1
If objWord.Characters(i).Text <> " " And objWord.Characters(i).Font.ColorIndex = wdColorBlack Then
objWord.Characters(i).Delete
End If
Next i

Next

' MsgBox "Done.", vbOKOnly, "Done"

End Sub

@ggre1335 Starting with the result of my previous procedure, after much trial and error, I was able to produce

Doug_Robbins_Word_MVP_0-1656290884662.png

As I recall the steps were (with the font format set to White, Background 1 for the Find what control:

  1. Replace ^S with ^&^p (or it may have been ^p^& 
  2. Replace ^S^p (or it may have been ^p^S) with ^p
  3. Replace ^W with nothing
  4. Using WIldcards replace ^13{1,} with ^p
  5. After unchecking Use Wildcards, replace ^p with nothing

^S finds any letter

^& represents the Find what text

^w finds white space

 

@Doug_Robbins_Word_

 

I appreciate all the help. Walk me thru your steps

  1. Replace ^S with ^&^p (or it may have been ^p^& 
  2. Replace ^S^p (or it may have been ^p^S) with ^p
  3. Replace ^W with nothing
  4. Using WIldcards replace ^13{1,} with ^p
  5. After unchecking Use Wildcards, replace ^p with nothing

^S finds any letter

^& represents the Find what text

^w finds white space

 

where is all the above taking place

if you could elaborate as to your steps in deleting all the spaces

@ggre1335 Starting with your original file:

  1. Access the Find and Replace dialog and click on More and then on Format>Font and select Automatic from the Font color dropdown in Find Font dialog
  2. In the Find what control, insert ^$
  3. In the Replace with control, insert ^& followed by a space
  4. Click on Replace All
  5. In the Find what control, insert a space followd by ^$
  6. In the Replace with control, insert ^p
  7. Click on Replace All
  8. Check the Use wildcards box
  9. In the Find what control, insert ^13{1,}
  10. In the Replace with control, insert ^p
  11. Click on Replace All
  12. Uncheck the Use wildcards box
  13. In the Find what control, insert ^w
  14. Leave the Replace with control empty
  15. Click on Replace All
  16. In the Find what control, insert ^p
  17. Leave the Replace with control empty
  18. Click on Replace All

@Doug_Robbins_Word_MVP 

Having a problem following your steps

step 2 In the Find what control, insert ^S

is that a caret S or special character followed by a S

special char S is not a valid char for find what box

i'll take it one step at at a time

when I resolve this

I'll reply

@ggre1335 As indicated in one of my earlier responses ^S is the Special for Any letter

 

Doug_Robbins_Word_MVP_0-1656447903067.png

 

@Doug_Robbins_Word_MVP 

thank you for your response. If you look at your step by step instructions step 1 says

  1. In the Find what control, insert ^S -- that's not an S in your latest response. It is supposed to be the pull-down for any char. which looks like a $. not an S.
  2. I tried to follow the succeeding steps. I would need you to show me an image of what each pull-down looks like . Just like you did in your latest response
  3. Really appreciate all the help

 

I have modified steps 2 and 5 to replace ^S with ^$

I would have thought that you could have tried that yourself.