Word spacing & Sentence length

  • Thread starter Syed Zeeshan Haider
  • Start date
S

Syed Zeeshan Haider

Hello Everybody,
I have two questions about VBA of word.

1. Is there any way to find out and control the distance/space between
words as we do with characters (character spacing)?
2. Is there any way to find out the length of a given sentence in points
for a given font (as different fonts have different apparent sizes)?

Thank you,
 
R

Robert M. Franz (RMF)

Hello Syed
1. Is there any way to find out and control the distance/space between
words as we do with characters (character spacing)?

Just to clarify the question: are you talking about "space" width in a
justified paragraph or in any other kind?

Because, in the former kind, Word decides how big the spaces are
depending on how much space is still on the line (it does this a good
deal better with one of the WP compatibility options, BTW). In the
latter, they should all be equal and you are down to distance between
characters.

Greetinx
Robert
 
H

Helmut Weber

Hi Robert,

yes.
Distance between words is nothing else than
distance between the last character of a word
and the first character of the next word.

I don't know what the OP wants to now exactly.
Things might get pretty complicated, if a sentence spans
over more than one line or from one page to the other.

@Syed:

Basically, it's this, with the insertion point
at the end of a word.

Sub Test345()
Dim p1 As Single
Dim p2 As Single
p1 = selection.Information(wdHorizontalPositionRelativeToPage)
selection.MoveRight
p2 = selection.Information(wdHorizontalPositionRelativeToPage)
MsgBox p2 - p1 ' distance in points
End Sub

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
S

Syed Zeeshan Haider

Thank you for your response!

Yes, I am talking about "space" width in a justified paragraph or in any
other kind. Word 2003 supports my native language but a certain kind of
formatting, which is required for poetry in my language, is not provided. I
was thinking about working out that kind of formatting using VBA.
In my language, i.e. Urdu, all lines of a poem must have same visual length.
In hand writing and calligraphy, it can be achieved by increasing word
spacing of smaller lines; an example can be seen at
http://www.urdupoint.com/poetry/poet/32/poetry/1355_big.gif. I am wishing to
achieve same affect in Word using VBA.

P.S. Urdu is a right-to-left language.

Thanks,
 
H

Helmut Weber

Hi Syed,

this is hard stuff for western people.
Could it be, that you only have problems with
the last line in a paragraph?

If so, a [shift return] at the end of the last line
would adjust that line, too.

And leave you with an empty line at the end of that paragraph.

But maybe, this is desired anyway.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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