none
How to detect an empty Word document? RRS feed

  • Question

  • Hi all, 

    I want to know is there a macro to detect an empty document automatically.

    Then according to the result, it can return something like a message box, indicating if it's empty or not.

    Thanks.

    Regards,

    VC

    Tuesday, April 11, 2017 3:44 AM

Answers

  • For example:

    Sub TestEmpty()
        If Len(ActiveDocument.Content) = 1 Then
            MsgBox "The active document is empty!", vbInformation
        End If
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by CNL777 Wednesday, April 12, 2017 1:17 AM
    Tuesday, April 11, 2017 5:27 AM

All replies

  • For example:

    Sub TestEmpty()
        If Len(ActiveDocument.Content) = 1 Then
            MsgBox "The active document is empty!", vbInformation
        End If
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by CNL777 Wednesday, April 12, 2017 1:17 AM
    Tuesday, April 11, 2017 5:27 AM
  • Thank you Hans!

    Have a good day.

    Wednesday, April 12, 2017 1:16 AM