How best to identify that no chars appear in a given page? (In Word.)

Go To


I'm faced with the prospect of blank pages scattered intermittently in a Word doc, which I'd like to discard. But I need to identify them in VBA first. There are spots in each where a caret lands if I click on the sheet.

But I don't know how to progress from there. How to instruct Word via VBA to identify whether the sheet has content in it?

2012-04-03 22:35
by M M


Something on these lines may suit.

j = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)

For i = j To 1 Step -1
    NotEmpty = True
    Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=CStr(i)
    Selection.GoTo What:=wdGoToBookmark, Name:="\page"
    If Selection.Characters.Count < 3 Then
        NotEmpty = False
        For Each c In Selection.Characters
            If Asc(c) > 13 Then
                ''Possibly not empty
                NotEmpty = True
            End If
    End If
    If NotEmpty = False Then
    End If
2012-04-03 23:30
by Fionnuala
That's quite incredible, Remou. You saved my project. Thanks - M M 2012-04-04 01:18