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.

Re: How to change the delimiter? by Jonathan

Jonathan
Thu Oct 20 08:19:37 CDT 2005

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.

--
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

<khairule@hotmail.com> wrote in message
news:1129809716.712989.197310@g44g2000cwa.googlegroups.com...
> 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.
>