Insert Tabs Between words
How can we do a replace by format when we want to find a space between words in Microsoft Word that the first word has a different font then the second?
Example: word1 Word2
we want to put a tab in the space between the 2 words
We have the following macro but only works on first line
Sub ScratchMacro()
Dim oWord As Range
Dim oRgn As Range
For Each oWord In ActiveDocument.Range.Words
If oWord.Font.Name = "Tahoma" Then
If oWord <> vbTab Then
On Error GoTo Err_Handler
If oWord.Words.Last.Next.Font.Name = "Times New Roman" Then
oWord = Replace(oWord, " ", vbTab)
End If
End If
End If
Next oWord
lbl_Exit:
Exit Sub
Err_Handler:
Resume lbl_Exit
End Sub
|