Thank you Rory, I got it to work using ActiveDocument as you suggested. I truly appreciate you not giving me the answer because it's good for me to figure it out with a nudge in the right direction. You're a star!!
Cheers
Debra
Code
Dim docReport As Document
Dim rngReport As Range
Dim strDocName As String
Dim strReport1, strReport2 As String
Dim i As Integer
Set docReport = Documents.Add
Set rngReport = docReport.Range
With rngReport
.Text = "MACRO USAGE" & vbCr
.Font.Bold = True
.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.EndKey
Selection.MoveEnd Unit:=wdLine, Count:=2
.Collapse direction:=wdCollapseEnd
End With
Selection.EndKey
With rngReport
.Text = vbCr & "Documents with 50+ fields" & vbCr
.Font.Bold = True
.ParagraphFormat.Alignment = wdAlignParagraphLeft
.Collapse direction:=wdCollapseEnd
.Bookmarks.Add ("bmkReport1")
End With
With rngReport
.Text = vbCr & "Documents with less than 50 fields" & vbCr
.Font.Bold = True
.ParagraphFormat.Alignment = wdAlignParagraphLeft
.Collapse direction:=wdCollapseEnd
.Bookmarks.Add ("bmkReport2")
End With
For i = 1 To Documents.Count
strDocName = Documents(i).Name
'If a Document has 50 fields or more in it then the client would
'like the macro to automatically update all the fields in the
'document.
If Documents(i).Fields.Count >= 50 Then
strReport1 = "> 50 " & strDocName & vbCr
With ActiveDocument.Bookmarks("bmkReport1").Range
.Select
.Text = strReport1
.Font.Bold = False
.Paragraphs.Alignment = wdAlignParagraphLeft
End With
Else
If i < 20 Then
'only the first 20 fields are updated, any other's should be ignored.
strReport2 = "< 20 " & strDocName & vbCr
Documents(i).Fields.Update
With rngReport.Bookmarks("bmkReport2").Range
.Select
.Text = strReport2
.Font.Bold = False
.ParagraphFormat.Alignment = wdAlignParagraphLeft
End With
End If
End If
Next i
Display More