Share via

Remove multiple pages from multiple documents

Anonymous
2014-02-20T17:06:26+00:00

If I have 50 documents and I need to remove the first 5 pages of each document, what would you suggest as the most efficient method for doing this?

Is it possible to create a macro? Do you know of a program that would help me? Any help would be appreciated!

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2014-02-21T02:49:43+00:00

    It can possibly be down with a macro, the only issue being that "pages" in Word is a little bit meaning less and it would be better if we knew that the pages to be deleted were all in a separate Section or Sections of the document.

    However, if you have all of the documents in a folder by themselves, the following code should delete the first five pages from each:

    Dim fd As Dialog

    Dim strFolder As String

    Dim strFile As String

    Dim aDoc As Document

    Dim i As Long

    Set fd = Application.FileDialog(msoFileDialogFolderPicker)

    With fd

        .Title = "Select the folder that contains the files from which you want to delete the pages."

        If .Show = -1 Then

            strFolder = .SelectedItems(1) & ""

        Else

            MsgBox "You did not select a folder."

            Exit Sub

        End If

    End With

    strFile = Dir$(strFolder & "*.doc")

    While strFile <> ""

        Set aDoc = Documents.Open(strFolder & strFile)

        For i = 1 To 5

            aDoc.Bookmarks("\page").range.Delete

        Next i

        aDoc.Save

        aDoc.Close

        strFile = Dir$()

    Wend

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments