Check for blank document

A

andreas

Dear Experts:

How come that if I run this If-Statement on a blank document the
msgbox does not get activated?

Help is much appreciated. Thank you in advance. Regards, Andreas

If ActiveDocument.Characters.Count = 0 Then
MsgBox "blank document", vbCritical, "blank document"
End If
 
G

Graham Mayor

Because a blank document does not contain 0 characters but 1

MsgBox ActiveDocument.Characters.Count


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
F

fumei via OfficeKB.com

Hi andreas. This is a crucial point of the Word document model. ALL Word
documents have at least one paragraph mark contained in at least one Section.
It is literally impossible to have a "blank" document.

Graham said:
Because a blank document does not contain 0 characters but 1

MsgBox ActiveDocument.Characters.Count
Dear Experts:
[quoted text clipped - 6 lines]
MsgBox "blank document", vbCritical, "blank document"
End If
 
A

andreas

Because a blank document does not contain 0 characters but 1

MsgBox ActiveDocument.Characters.Count

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>







- Show quoted text -

ok, great thank you very much. Regards, Andreas
 
A

andreas

Hi andreas.  This is a crucial point of the Word document model.  ALLWord
documents have at least one paragraph mark contained in at least one Section.
It is literally impossible to have a "blank" document.

Graham said:
Because a blank document does not contain 0 characters but 1
MsgBox ActiveDocument.Characters.Count
[quoted text clipped - 6 lines]
MsgBox "blank document", vbCritical, "blank document"
End If

Ok, Thank you very much for your help. Regards, Andreas
 

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