page numbering macro causes crash...

Hi.  I have this code and it runs okay as long as I don't have too many pages with graphics on them.  I can re-create the crash many times and would like to know if there is something else I can add to this so that the crash does not happen.  Maybe something that will check when the page deletion process is taking longer than normal and the macro will pause to allow processing?

Dim s As Shape

    For Each pageThis In ActiveDocument.Pages
        Set sPageNumThis = pageThis.Shapes.FindShape("pagetotal")
        If Not sPageNumThis Is Nothing Then
            sPageNumThis.Text.Story = CStr(ActiveDocument.Pages.Count)
        End If
    Next pageThis

  • After some thought.  I think I have a temporary solution that would work  There needs to be a keypress listen, when SHIFT is pressed, macro will not run.  I can use this to stop it from running until all pages are deleted and then I can let it run afterwards.

    that would be great.

Reply Children