Macro to delete pages

I am trying to get a macro that will delete all of the pages in the current document that have less than 5 layers.  I tried the code below, but it doesn't work.  I'm new to VBA so this might be way off. 

Sub Macro1()

Dim p As Page
Dim i&

For i = 1 To ActiveDocument.Pages.Count
Set p = ActiveDocument.Pages(i)
If ActivePage.Layers.Count < 5 Then ActivePage.Delete

Next i

End Sub