# Word VBA MACRO adding blank pages to start of document



## jacinthn (Sep 27, 2013)

I have below macro for coping all open word docs into a "master" sheet and adding a page break then a blank page after each doc copied.
it works fine, however its adding 2 blank pages at the top of the document when it copies, so my first 2 pages on my master are blank.
I am not sure how to get the first document copied to the first page in the master sheet, 
so i can stop getting those 2 blank pages on top.

Any ideas?


thanks




Sub DLS()</SPAN>
Dim i As Integer</SPAN>
Dim strKeepOpen As String</SPAN>
strKeepOpen = ("master.docm")</SPAN></SPAN>


For i = Documents.Count To 1 Step -1</SPAN>
If Documents(i).Name <> strKeepOpen Then Documents(i).Activate</SPAN>
Selection.WholeStory</SPAN>
Selection.Copy</SPAN>
If ActiveDocument.Name <> strKeepOpen Then ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges</SPAN>
Windows("master.docm").Activate</SPAN>
Selection.GoTo wdGoToBookmark, , , "\EndOfDoc"</SPAN>
Selection.PasteAndFormat (wdPasteDefault)</SPAN>
With ActiveWindow.View</SPAN>
.ShowRevisionsAndComments = False</SPAN>
.RevisionsView = wdRevisionsViewFinal</SPAN>
End With</SPAN>
Selection.InsertBreak Type:=wdPageBreak</SPAN>
Selection.InsertNewPage</SPAN>



Next i</SPAN>


End Sub</SPAN>


----------



## Worf (Sep 28, 2013)

If you are starting with a blank master document, this will work:


```
' this is a Word macro


Sub DLS()
Dim i%, strKeepOpen$


strKeepOpen = ("master.docm")


For i = Documents.Count To 1 Step -1
    If Documents(i).Name <> strKeepOpen Then Documents(i).Activate
    Selection.WholeStory
    Selection.Copy
    If ActiveDocument.Name <> strKeepOpen Then ActiveDocument.Close SaveChanges:=0
    Windows("master.docm").Activate
    If i = Documents.Count Then
        Selection.GoTo wdGoToBookmark, , , "\StartOfDoc"
    Else
        Selection.GoTo wdGoToBookmark, , , "\EndOfDoc"
    End If
    Selection.PasteAndFormat (wdPasteDefault)
    With ActiveWindow.View
        .ShowRevisionsAndComments = False
        .RevisionsView = wdRevisionsViewFinal
    End With
    Selection.InsertBreak Type:=wdPageBreak
    Selection.InsertNewPage
Next


End Sub
```


----------



## jacinthn (Sep 30, 2013)

worked like a charm thanks so much for the help. Greatly Appreciated


----------



## Worf (Sep 30, 2013)

You are welcome and thanks for the feedback


----------

