Macro to check brackets

V

Victor Delta

When using brackets in Word, I often manage to forget to include the closing
bracket, especially if it quite a long sentence.

Does anyone please know if there is a macro, of some other way, for checking
that there are as many opening brackets as there are closing brackets in a
document?

TIA

V
 
I

Iceman

In this group Victor Delta wrote in message
When using brackets in Word, I often manage to forget to include the
closing bracket, especially if it quite a long sentence.

Does anyone please know if there is a macro, of some other way, for
checking that there are as many opening brackets as there are closing
brackets in a document?

You don't need a macro to do that. Word's search and replace function
automatically reports on the number of replacements made.

Simply open the Replace dialog and replace the character you want to count
with itself (in other words, replace [ with [ or ] with ]). Because you are
replacing the character with itself, no observable change will be made to
the document, but Word will dutifully tell you that x number of replacements
were made, giving you the character count you need.

Note, though, that characters in headers and footers and automatically
generated numbers won't be counted.
 
S

Suzanne S. Barnhill

In more recent versions of Word, you don't even have to replace: in the Find
dialog there's a Find All or "Find in" option that just finds and selects
all the instances and tells you how many there are.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

Iceman said:
In this group Victor Delta wrote in message
When using brackets in Word, I often manage to forget to include the
closing bracket, especially if it quite a long sentence.

Does anyone please know if there is a macro, of some other way, for
checking that there are as many opening brackets as there are closing
brackets in a document?

You don't need a macro to do that. Word's search and replace function
automatically reports on the number of replacements made.

Simply open the Replace dialog and replace the character you want to count
with itself (in other words, replace [ with [ or ] with ]). Because you
are replacing the character with itself, no observable change will be made
to the document, but Word will dutifully tell you that x number of
replacements were made, giving you the character count you need.

Note, though, that characters in headers and footers and automatically
generated numbers won't be counted.
 
V

Victor Delta

Thanks to you both but a couple of rather more elegant solutions here
http://windowssecrets.com/forums/showthread.php/139527-Spotting-missing-brackets-in-Word

V

Suzanne S. Barnhill said:
In more recent versions of Word, you don't even have to replace: in the
Find dialog there's a Find All or "Find in" option that just finds and
selects all the instances and tells you how many there are.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

Iceman said:
In this group Victor Delta wrote in message
When using brackets in Word, I often manage to forget to include the
closing bracket, especially if it quite a long sentence.

Does anyone please know if there is a macro, of some other way, for
checking that there are as many opening brackets as there are closing
brackets in a document?

You don't need a macro to do that. Word's search and replace function
automatically reports on the number of replacements made.

Simply open the Replace dialog and replace the character you want to
count with itself (in other words, replace [ with [ or ] with ]). Because
you are replacing the character with itself, no observable change will be
made to the document, but Word will dutifully tell you that x number of
replacements were made, giving you the character count you need.

Note, though, that characters in headers and footers and automatically
generated numbers won't be counted.
 
S

Suzanne S. Barnhill

Well, if you want a macro, then that's a macro.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

Victor Delta said:
Thanks to you both but a couple of rather more elegant solutions here
http://windowssecrets.com/forums/showthread.php/139527-Spotting-missing-brackets-in-Word

V

Suzanne S. Barnhill said:
In more recent versions of Word, you don't even have to replace: in the
Find dialog there's a Find All or "Find in" option that just finds and
selects all the instances and tells you how many there are.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

Iceman said:
In this group Victor Delta wrote in message

When using brackets in Word, I often manage to forget to include the
closing bracket, especially if it quite a long sentence.

Does anyone please know if there is a macro, of some other way, for
checking that there are as many opening brackets as there are closing
brackets in a document?

You don't need a macro to do that. Word's search and replace function
automatically reports on the number of replacements made.

Simply open the Replace dialog and replace the character you want to
count with itself (in other words, replace [ with [ or ] with ]).
Because you are replacing the character with itself, no observable
change will be made to the document, but Word will dutifully tell you
that x number of replacements were made, giving you the character count
you need.

Note, though, that characters in headers and footers and automatically
generated numbers won't be counted.
 

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