Many thanks in anticipation of your help. I have the following code to interrogate a directory and provide a report of those documents which are empty. Ideally I’d like these documents to be deleted – the code so far just produces a report of those documents which are empty. Can anyone enlighten me on a code fix to either (a) delete the empty document or ( copy the empty document to another folder.
Dim CountedSet As CountedSet
Dim sString As String
Dim vFileName As Variant
Set CountedSet = New CountedSet
Documents.Add Template:=”Normal”, NewTemplate:=False, DocumentType:=0
With Application.FileSearch
.FileName = “*.*”
.LookIn = “i:Test”
.Execute
End With
For Each vFileName In Application.FileSearch.FoundFiles
Application.Documents.Open vFileName
Set myRange = ActiveDocument.Range
If ActiveDocument.Content.StoryLength = 1 Then
sString = vFileName
CountedSet.Add sString
End If
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Next vFileName
CountedSet.Report