Hebrew / right-to-left text

T

Terri N

I am so close...the Hebrew text I am inserting into my English document has a
couple of glitches left. I'm wondering if there is a utility I can use.
I've already installed a Hebrew keyboard, which fixed almost everything. The
last two problems:

1. When I insert a bit of Hebrew into the middle of a paragraph, I then
block out that Hebrew text and hit the "right-to-left" icon. But instead of
applying it to the Hebrew, it applies it to the entire paragraph.

2. The punctuation is drifting. For instance, if there is a colon, instead
of it being attached to the previous letter, it attaches to the next letter,
after the space. So it looks sort of like this :with the colon. I can't
just reverse the space and colon, because if I delete the space, the "s"
deletes also. If I delete the colon, the "w" deletes also.

Any guidance?
 
P

Peter T. Daniels

1. What do you mean by "block out"? If the Hebrew text has been typed
with a proper Unicode Hebrew font, it should behave exactly as it
needs to -- this week I've been typing Arabic words in the middle of
German text, and all is well. The paragraph remains left-to-right,
because that's the direction of your main text. (If you wanted an
English word in the middle of a Hebrew paragraph, you wouldn't switch
the paragraph to left-to-rignt.)

2. I did warn you that funny things happen at the interface. The most
practical way to deal with stray punctuation is to select the wrong
items and then press Backspace or Delete (or Ctrl-X), not to try just
deleting them. The most practical way to insert punctuation at an
interface is to type some spaces, put the colon or whatever in the
middle of them, and select, then delete, the spaces that are in the
wrong place. (If you type the punctuation while you're typing the
text, there's no problem, but since you're inserting rather than
typing, you'll encounter finicky behavior.)

I don't know why adjacent characters are deleting, but if you select
the space or colon and then delete, it probably won't happen.
 
T

Terri N

I selected the Hebrew phrase, then chose right-to-left (RTL), hoping that
only the phrase itself would read RTL, per my customer's request. But the
entire paragraph switched to RTL. So Word can't switch just the phrase? And
you're saying that if you're typing a left-to-right English paragraph, the
Hebrew phrase in the middle of it is going to have to read left to right as
well?

I'm having a hard time locating a Unicode Hebrew font--does a font that
supports all the Hebrew characters (including vowels) come with Windows? I
may be missing it. There is a font called "David" on my list.

The person who will be typing the text is using a Mac, and I'll then have to
paste it into my Word document and convert it to whatever font I'll be using.
I found one online called Ezra that the customer likes, but it doesn't
mention Unicode in the name.

Thank you for the hint re: the punctuation. I've tried it with a little
success in a couple of spots, and I'll keep trying and see if I can get the
hang of it.

Thanks for your help, Peter...this job is a huge challenge for me. But, as
with most problems, I'm also learning a lot.
 
P

Peter T. Daniels

I selected the Hebrew phrase, then chose right-to-left (RTL), hoping that
only the phrase itself would read RTL, per my customer's request.  But the
entire paragraph switched to RTL.  So Word can't switch just the phrase?  And
you're saying that if you're typing a left-to-right English paragraph, the
Hebrew phrase in the middle of it is going to have to read left to right as
well?

Of course not. Are you in fact not using a Unicode Hebrew font? If
you're using a Hebrew font that just puts the letters in the a-z, A-Z
etc. slots, then yes, you have to type backwards. But then you might
as weill just type transliterations of the Hebrew!
I'm having a hard time locating a Unicode Hebrew font--does a font that
supports all the Hebrew characters (including vowels) come with Windows?  I
may be missing it.  There is a font called "David" on my list.

Fonts with the full complement of Hebrew characters include Arial,
Tahoma, and Times New Roman. Fonts intended for Modern Hebrew, such as
David, don't have the accents (cantillation marks) used only in Bible
texts. But David _is_ a Unicode font (it came with either Windows or
Office, since the only Hebrew I ever downloaded was SBL Hebrew, which
is made especially for typing all the complicated stuff in the Bible
text).
The person who will be typing the text is using a Mac, and I'll then haveto
paste it into my Word document and convert it to whatever font I'll be using.
 I found one online called Ezra that the customer likes, but it doesn't
mention Unicode in the name.

If it comes in different versions for Mac and Windows, then it
probably isn't a Unicode font. Possibly if you hunt around you can
find a version of Ezra that's been Unicode-encoded.

Ah -- Ezra is from the SIL, so it's free; it is Unicode; and it has
the full set of characters. It looks like the type found in early-20th-
century Conservative prayer books. (And a lot of the Haggadahs you'll
find next March.)
 
G

Graham Mayor

Peter said:
IF you're using a Hebrew font that just puts the letters in the a-z, A-Z
etc. slots, then yes, you have to type backwards.

If the font requires that the text is typed backwards (and I hasted to add I
have no knowledge of right left languages) that can easily be fixed with a
macro that will reverse the order of selected text eg

Sub ReverseCharacters()
Dim sText As String
sText = Selection.Range.Text
If Len(sText) < 2 Then
MsgBox "You must select at least 2 characters!", _
vbCritical, "Reverse Characters"
Exit Sub
End If
For i = Len(sText) To 1 Step -1
Selection.TypeText Mid(sText, i, 1)
Next i
End Sub

http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
T

Tony Jollans

I agree with Peter - this should just work, assuming Hebrew support is
enabled and the text is marked as Hebrew.

Also, I'm not sure just reversing text with a macro will deal with line
breaks properly.
 
P

Peter T. Daniels

As Tony noted, line breaks will be a problem -- but also, if there's
more than one word, will it reverse each word independently, or do you
need to type your whole clause backward, last-word-first?

This would of course be most useful to make up for the most glaring
omission in Word's editing tools since the very beginning (since lots
of other DTP apps have it) -- "transpose two characters"!
 
G

Graham Mayor

The macro simply re-orders the selected text from end to start as if you had
typed it backwards. I did not envisage using it for long texts, merely
phrases inserted into an English document. However as I said I have no
personal knowledge of left to right languages.

As for transposing two selected characters, that macro would work, but I
suspect the following refinement might suit the task better

Sub Transpose()
Dim sText As String
sText = Selection.Range.Text
If Len(sText) <> 2 Then
MsgBox "You must select 2 characters!", _
vbCritical, "Transpose Characters"
Exit Sub
End If
If Selection.Range.Characters(1).Case = 1 _
And Selection.Range.Characters(2).Case = 0 Then
Selection.TypeText UCase(Mid(sText, 2, 1)) & _
LCase(Mid(sText, 1, 1))
Else
Selection.TypeText Mid(sText, 2, 1) & _
Mid(sText, 1, 1)
End If
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Peter T. Daniels

Wow -- I don't think anyone's bothered to fix the _case_ where it's
involved in a transposition before! And Ctrl-T is the Hanging Indent
shortcut -- which I always do with either the Ruler or the Paragraph
Format tool, since anything automatic would have to be adjusted
anyway,so it will have its own perfectly intuitive command! Thanks!
Now to relocate the install-macro instructions ...
 
P

Peter T. Daniels

I should Bookmark that in my browser ...

One other thing (I hoped to add this before you saw the thread
again!): can you make it work on two characters that the cursor is
between, rather than having to select the two characters?
 
G

Graham Mayor

OK, but a little more error handling wouldn't hurt (and it would be possible
to either put the cursor between the characters or select them, but I
haven't time to add that now. Maybe tomorrow).

Sub Transpose()
Dim oRng As Range
Dim sText As String
On Error GoTo ErrorHandler
If ActiveDocument.Characters.Count > 2 Then
Set oRng = Selection.Range
If Len(oRng) <> 0 Then
MsgBox "You must place the cursor between the 2 characters to be
transposed!", _
vbCritical, "Transpose Characters"
Exit Sub
End If
With oRng
.Start = .Start - 1
.End = .End + 1
.Select
sText = .Text
End With
With Selection
If .Range.Characters(1).Case = 1 _
And .Range.Characters(2).Case = 0 Then
.TypeText UCase(Mid(sText, 2, 1)) & _
LCase(Mid(sText, 1, 1))
Else
.TypeText Mid(sText, 2, 1) & _
Mid(sText, 1, 1)
End If
.MoveLeft wdCharacter
End With
Else
MsgBox "Empty document", _
vbCritical, "Transpose Characters"
End If
End
ErrorHandler:
If Err.Number = 4248 Then
MsgBox "No document open", _
vbCritical, "Transpose Characters"
End If
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Greg Maxey

Graham,

Seems that StrReverse would be an easier method.

Sub Transpose()
Dim myRange As Word.Range
Dim bSpace As Boolean
Dim pStr As String
Dim i As Long
Dim oWord As Word.Range
Set myRange = Selection.Range
bSpace = False
If myRange.Words.Count > 1 Then
If MsgBox("If you want to transpose the entire selection select
yes. Ohterwise only words will be transposed.", vbQuestion + vbYesNo,
"Traspose Entire Phrase") = vbYes Then
pStr = myRange.Text
myRange.Text = StrReverse(pStr)
Else
For i = 1 To myRange.Words.Count
If myRange.Words(i).Characters.Last = Chr(32) Then bSpace = True
pStr = StrReverse(Trim(myRange.Words(i).Text))
If bSpace Then pStr = pStr & " "
myRange.Words(i).Text = pStr
bSpace = False
Next
End If
Else
pStr = myRange.Text
myRange.Text = StrReverse(pStr)
End If
End Sub
 
T

Tony Jollans

I think this is fraught with difficulty - almost by definition you are
dealing with complex scripts, and you really need to examine the selection
for combining characters. I don't know Hebrew, but just as an example,
consider the character בְ - this is a letter bet (ב) with a combining point
sheva (Ö°) below it - it is two characters (overlaid) in Word and swapping
them round - indeed doing anything with them other than treating them as a
single unit - is totally destructive.

I hope this shows up properly in your newsreader - if not, the characters
are U+5D1 (bet) and U+5B0 (sheva).
 
P

Peter T. Daniels

Oh, I wasn't talking about typos in Hebrew -- though in Modern Hebrew
the problem you raise will rarely come up, as the vowel points are
rarely used (except in didactic texts and poetry).

So, thanks again to Graham for a transposing tool!
 
G

Graham Mayor

Let's say 'alternative' rather than 'easier' ;) However for the additional
issue of two transposed characters, it does not address the capitalisation
where the transposed characters begin a sentence.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

Following up with the revised version of the transposition macro I mentioned
yesterday: The following will transpose either two selected characters or
the characters either side of the cursor and allows for those cases where
the cursor is not located between two characters or more than two characters
are selected. The cursor is left between the transposed characters so
repeated use of the macro will toggle the transposition back and forth. I
have added this version to my web page
http://www.gmayor.com/word_vba_examples.htm#Transpose

Sub Transpose()
Dim oRng As Range
Dim sText As String
Dim Msg1 As String
Dim Msg2 As String
Dim Msg3 As String
Dim MsgTitle As String
Msg1 = "You must place the cursor between " & _
"the 2 characters to be transposed!"
Msg2 = "There are no characters to transpose?"
Msg3 = "There is no document open!"
MsgTitle = "Transpose Characters"
On Error GoTo ErrorHandler
If ActiveDocument.Characters.Count > 2 Then
Set oRng = Selection.Range
Select Case Len(oRng)
Case Is = 0
If oRng.Start = oRng.Paragraphs(1).Range.Start Then
MsgBox Msg1, vbCritical, MsgTitle
Exit Sub
End If
If oRng.End = oRng.Paragraphs(1).Range.End - 1 Then
MsgBox Msg1, vbCritical, MsgTitle
Exit Sub
End If
With oRng
.Start = .Start - 1
.End = .End + 1
.Select
sText = .Text
End With
Case Is = 1
MsgBox Msg1, vbCritical, MsgTitle
Exit Sub
Case Is = 2
sText = Selection.Range.Text
Case Else
MsgBox Msg1, vbCritical, MsgTitle
Exit Sub
End Select
With Selection
If .Range.Characters(1).Case = 1 _
And .Range.Characters(2).Case = 0 Then
.TypeText UCase(Mid(sText, 2, 1)) & _
LCase(Mid(sText, 1, 1))
Else
.TypeText Mid(sText, 2, 1) & _
Mid(sText, 1, 1)
End If
.MoveLeft wdCharacter
End With
Else
MsgBox Msg2, vbCritical, MsgTitle
End If
End
ErrorHandler:
If Err.Number = 4248 Then
MsgBox Msg3, vbCritical, MsgTitle
End If
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Greg Maxey

Graham,.

Yes quite correct. I have seen that term so much recently in this group
that it caught

I must be missing the concept. If I type:

Mr Smith goes to Washington

place the cursor between the M and r of Mr then use your method I get:

RmMr Smith goes to Washington

If I select Mr and use my (slightly revised) method I get:

Rm Smith goes to Washington

Sub Transpose()
Dim myRange As Word.Range
Dim bSpace As Boolean
Dim pStr As String
Dim i As Long
Dim oWord As Word.Range
Set myRange = Selection.Range
bSpace = False
If myRange.Words.Count > 1 Then
If MsgBox("If you want to transpose the entire selection select yes.
Otherwise only words will be transposed.", vbQuestion + vbYesNo, "Traspose
Entire Phrase") = vbYes Then
pStr = myRange.Text
myRange.Text = StrReverse(pStr)
myRange.Case = wdTitleSentence
Else
For i = 1 To myRange.Words.Count
If myRange.Words(i).Characters.Last = Chr(32) Then bSpace = True
pStr = StrReverse(Trim(myRange.Words(i).Text))
If bSpace Then pStr = pStr & " "
myRange.Words(i).Text = pStr
On Error Resume Next
myRange.Words(i).Case = wdTitleSentence
bSpace = False
Next
End If
Else
pStr = myRange.Text
myRange.Text = StrReverse(pStr)
myRange.Case = wdTitleSentence
End If
End Sub


Graham said:
Let's say 'alternative' rather than 'easier' ;) However for the
additional issue of two transposed characters, it does not address
the capitalisation where the transposed characters begin a sentence.

--
Greg Maxey

See my web site http://gregmaxey.mvps.org
for an eclectic collection of Word Tips.

"It is not the critic who counts, not the man who points out how the
strong man stumbles, or where the doer of deeds could have done them
better. The credit belongs to the man in the arena, whose face is
marred by dust and sweat and blood, who strives valiantly...who knows
the great enthusiasms, the great devotions, who spends himself in a
worthy cause, who at the best knows in the end the triumph of high
achievement, and who at the worst, if he fails, at least fails while
daring greatly, so that his place shall never be with those cold and
timid souls who have never known neither victory nor defeat." - TR
 
G

Graham Mayor

If you use my last posted version and put the cursor between the M and r of
Mr, or select Mr, Mr Smith is transposed to Rm Smith, which is what was
intended. Neither of the simpler versions I posted yesterday, behave in the
manner you describe. The version posted this morning combines the two so
that a user may put the cursor between or select the characters to be
transposed.

The earlier macro in the thread, the theme of which you have developed, was
concerned more with re-typing a string backwards to attempt to correct a
right to left text that was not correctly formatted from right to left, but
as others have posted, this is not the best way to approach that topic. The
question about the transposition of 2 characters merely evolved from that.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Peter T. Daniels

I don't understand what you mean by "where the cursor is not located
between the two characters" -- does that simply mean that it works by
selecting two characters? And the following phrase means it will
reverse the sequence of any number of selected characters? (Both those
qualifications don't appear in the website description.)

I'll replace yesterday's macro with this one, so thank you again!

Also, I noticed a tiny glitch in your "installing macros" instructions
yesterday. I don't need to put Transpose on the QAT, but I do want a
keyboard shortcut. The instructions give the impression that you need
a button on the QAT to assign a shortcut to a macro, but t turns out
you don't -- just skip the step to add it to the QAT and go on to
click the Shortcut button. (However, the name of the macro does _not_
appear in the shortcut-assigning panel, as I'm accustomed to seeing
when I assign a shortcut to a character.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top