New page contains layers from previous page

When I use a macro to create a new page, the layers of the provious page appear on the new one.


The macro below was recorded by creating af new document, adding two layers to the first page,
adding a new page and one more and finally adding a new layer to this third page.
Now Page 1 contains Layers 1 to 3 (and the Guides layer), Page 2 has Layer 1 and Page 3 Layers 1 and 2,
all as intended.

I then delete the created document and run the newly created macro. Surprise: The layers Layer 2 and Layer 3
from Page 1 also apper on Pages 2 and 3, the latter now having two layers named Layer 2.
This is, of course, unwanted, but I cant figure out why this occurs. Any suggestions?

Best wishes
Holger Nielsen


Sub Macro7()
    ' Recorded 2017-11-14
    Dim createopt As StructCreateOptions
    Set createopt = CreateStructCreateOptions
    With createopt
        .Name = "TestPageLayerCreation"
        .Units = cdrMillimeter
        .PageWidth = 210#
        .PageHeight = 297#
        .Resolution = 300#
        .ColorContext = CreateColorContext2("sRGB IEC61966-2.1,ISO Coated v2 (ECI),Dot Gain 15%", BlendingColorModel:=clrColorModelCMYK)
    End With
    Dim doc1 As Document
    Set doc1 = CreateDocumentEx(createopt)
    Dim lr1 As Layer
    Set lr1 = ActivePage.CreateLayer("Layer 2")
    Dim lr2 As Layer
    Set lr2 = ActivePage.CreateLayer("Layer 3")
    Dim p1 As Page
    Set p1 = doc1.InsertPagesEx(1, False, ActivePage.Index, 8.267717, 11.692913)
    Dim p2 As Page
    Set p2 = doc1.InsertPagesEx(1, False, p1.Index, 8.267717, 11.692913)
    Dim lr3 As Layer
    Set lr3 = p2.CreateLayer("Layer 2")
End Sub