IF BLANK Macro Question

R

Ralph

I have a Macro that runs in MS-Word. I need to find
out if a document that a user is referencing/opening/using
is BLANK.

If the Document is BLANK notify the user with a message.
If the document is NOT BLANK (i.e more that 10 characters)
notify the user with a message box.

Can anyone help me?
 
J

Jean-Guy Marcil

Ralph was telling us:
Ralph nous racontait que :
I have a Macro that runs in MS-Word. I need to find
out if a document that a user is referencing/opening/using
is BLANK.

If the Document is BLANK notify the user with a message.
If the document is NOT BLANK (i.e more that 10 characters)
notify the user with a message box.

If Len(ActiveDocument.Range.Text) < 11 Then
MsgBox "This document contains less than 11 characters"
Else
MsgBox "This document contains more than 11 characters"
End If
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jean-Guy Marcil

Ralph was telling us:
Ralph nous racontait que :
I have a Macro that runs in MS-Word. I need to find
out if a document that a user is referencing/opening/using
is BLANK.

If the Document is BLANK notify the user with a message.
If the document is NOT BLANK (i.e more that 10 characters)
notify the user with a message box.

Please do not multipost.

If you want you can crosspost (Many newsgroups in the To: field when you
create your message.)

The reason is simple:
People may end up "wasting" their time answering a post that has already
been answered elsewhere, thus it may be very likely that their particular
response to a post be totally ignored if the reply received elsewhere was
satisfactory to the original poster.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
G

Greg Maxey

JGM

Is there any advantage by using
Len(ActiveDocument.Range.Text) < 11
over
ActiveDocument.Characters.Count < 11

??

Thanks.
 
J

Jean-Guy Marcil

Greg Maxey was telling us:
Greg Maxey nous racontait que :
JGM

Is there any advantage by using
Len(ActiveDocument.Range.Text) < 11
over
ActiveDocument.Characters.Count < 11

Not that I can think of... It is just that this was the first thing that
popped into my mind!

Now that you bring it up, I think that
ActiveDocument.Characters.Count
would be more accurate for this purpose (If there are tables for example,
the End of Cell marker will be counted as 2 characters by the Len function,
but as one by Characters.Count.)
Since he was talking about an almost blank document, I did not really think
that deep!
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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