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?
Something on these lines may suit.
ActiveDocument.Repaginate
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
Next
End If
If NotEmpty = False Then
Selection.Delete
End If
Next