Naming sentences

B

Brad

Can you "name" a sentence? If so, how is this done?

What I'm trying to do is to control what is being printed out in a document
and would like to be able to hide sentences and/or paragraphs. (Most likely
using VBA, of which I have some experience, which is more than what I can say
for using Word?
 
H

Helmut Weber

Hi Brad,
Can you "name" a sentence? If so, how is this done?
What I'm trying to do is to control what is being printed out in a document
and would like to be able to hide sentences and/or paragraphs. (Most likely
using VBA, of which I have some experience, which is more than what I can say
for using Word?

???

Maybe like that:

Sub Macro1()
Dim This As Range
Set This = ActiveDocument.Range.Sentences(3)
This.Font.Hidden = True
' ...
End Sub

But linguistic concepts like sentence and word are fuzzy,
and hiding ActiveDocument.Range.Sentences(3) does just the same.
So there is nothing gained.
 
B

Brad

Your suggestion worked - thank you. However, can I replace the (3) with a
"name"? That would be "marked" at the beginning and the end (in this case a
sentence, but could be a paragraph or a few words) so that no matter where it
is I can hide it.
 
H

Helmut Weber

Hi Brad,
Your suggestion worked - thank you. However, can I replace the (3) with a
"name"? That would be "marked" at the beginning and the end (in this case a
sentence, but could be a paragraph or a few words) so that no matter where it
is I can hide it.

hmm, I think you are looking for bookmarks.
From the user interface, select some text.
Sentence, paragraph, a few words, whatsoever.
On the menu bar, choose "Insert bookmark",
give it a name, and select "add".
From then on you got a named range.

Then, like that:

ActiveDocument.Bookmarks("Test").Range.Font.Hidden = True
--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
B

Brad

Thank you, from the Mid West


Helmut Weber said:
Hi Brad,


hmm, I think you are looking for bookmarks.
From the user interface, select some text.
Sentence, paragraph, a few words, whatsoever.
On the menu bar, choose "Insert bookmark",
give it a name, and select "add".
From then on you got a named range.

Then, like that:

ActiveDocument.Bookmarks("Test").Range.Font.Hidden = True
--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

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