Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

How to find a soft hyphen

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LC - 23 Oct 2006 17:45 GMT
I use the Word Selection object to "walk" every character of a text.
This works well until there is a soft hyphen inserted by Word for
breaking up a long word. The Selection object just doesn't see the soft
hyphen. I tried all sorts of objects like Range, Word, Character and
Find but nothing worked. Anyone knows how to "see" in Word VBA a soft
hyphen?

Thanks in advance
LC
Marco Pagliero - 24 Oct 2006 00:52 GMT
> I use the Word Selection object to "walk" every character of a text.
> This works well until there is a soft hyphen inserted by Word for
> breaking up a long word. The Selection object just doesn't see the soft
> hyphen. I tried all sorts of objects like Range, Word, Character and
> Find but nothing worked. Anyone knows how to "see" in Word VBA a soft
> hyphen?

It seems that soft hyphens don't actually exist: they are not contained
in the selection and they are also not saved in the document file.
Maybe Word adds them on-the-fly when displaying the page?

On the other hand, why do you need to see them in the first place?
Maybe we can find a solution for _this_ special problem.

Greetings

Marco P
LC - 24 Oct 2006 02:28 GMT
I'm writing a simple device-independent text-only EPS driver in word
VBA. So far I've got everything I need except the soft hyphenation. I
also suspect the soft hyphen is not stored anywhere. I thought of
marking a word and then walk each letter of the word checking for its
vertical position to detect a break but there must be a more elegant
solution.

> > I use the Word Selection object to "walk" every character of a text.
> > This works well until there is a soft hyphen inserted by Word for
[quoted text clipped - 13 lines]
>
> Marco P
Jezebel - 24 Oct 2006 02:43 GMT
You can infer the presence of soft hyphens by walking the displayed lines of
the document --

ActiveDocument.ActivePanes.Pages(1).Rectangles(1).Lines(1).Range

Compare each line range with the corresponding sub-range of the original in
the document body: if the last 'word' in the line is only part of a word in
the original, then a hyphen has been inserted. Conversely, if it IS a full
word, and it's not the final word of the paragraph, then the following
space(s) will have been omitted.

It sure ain't elegant, but faute de mieux.

> I'm writing a simple device-independent text-only EPS driver in word
> VBA. So far I've got everything I need except the soft hyphenation. I
[quoted text clipped - 20 lines]
>>
>> Marco P
LC - 25 Oct 2006 16:48 GMT
Thank you for responding. That gave me an idea. I walk a line of text,
character by character. When I see the last character is a letter, I do
a MoveRight wdWord, wdExtend and then count the number of characters
selected. If more than one, I assume there is a soft hyphen. It is
still not the "elegant" solution I was hoping for for it might fail in
some strange cases but it works reasonably well enough for me, for now
until I'll find a better solution.

Thanks
LC

> You can infer the presence of soft hyphens by walking the displayed lines of
> the document --
[quoted text clipped - 33 lines]
> >>
> >> Marco P

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.