Remove multiple pages from multiple documents

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!

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

Hope this helps,
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com
It's time to replace ‘Diversity, Equity & Inclusion’ with ‘Excellence, Opportunity & Civility’ - V Ramaswamy

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 5, 2023 Views 460 Applies to: