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 2005

Tip: Looking for answers? Try searching our database.

How to change the delimiter?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
khairule@hotmail.com - 20 Oct 2005 13:01 GMT
Hi,

I am using Word.Application.Document.Sentences to get all sentences in
a word document. By default, the VBA would return sentences delimited
by full stop. How could I change it to look for other delimiters, such
as a comma, or even custom define it?

For example, these are 2 sentences in a paragraph:

{##1##}The brown fox jumps over the lazy dog. {/##1##}{##2##}The brown
fox jumps over the lazy dog. {/##2##}

If I use Word.Application.Document.Sentences in a loop, it would return
me 3 lines:
line 1: {##1##}The brown fox jumps over the lazy dog.
line 2: {/##1##}{##2##}The brown fox jumps over the lazy dog.
line 3: {/##2##}

What I need is to have only these 2 sentences:
line 1:{##1##}The brown fox jumps over the lazy dog. {/##1##}
line 2:{##2##}The brown fox jumps over the lazy dog. {/##2##}

Please help. Thank you in advance.
Jonathan West - 20 Oct 2005 14:19 GMT
Hi khairule

Short answer is that you can't do this directly. The best thing to do is to
load the entire text of the document into a string variable, and then
process the string in whatever way you want. You can get the entire
unformatted text of the document into a string by assigning the
ActiveDocument.Content.Text property to a string.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

> Hi,
>
[quoted text clipped - 19 lines]
>
> Please help. Thank you in advance.
 
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.