Object Model Reference : Classes : D : Document : Methods : Document.Activate |
Sub Activate()
Member of Document
The Activate method opens a document in the main application window in CorelDRAW, if the window is not currently open, and makes the document active. A document in CorelDRAW is single-page drawing or a collection of single-page drawings that make up a multi-page document.
The following VBA example copies all objects from the active document to the second document, page by page, and then activates the second document.
Sub Test() |
Dim doc1 As Document, doc2 As Document |
Dim p As Page |
If Documents.Count <> 2 Then |
MsgBox "2 documents must be open" |
Exit Sub |
End If |
If ActiveDocument Is Documents(1) Then |
Set doc1 = Documents(1) |
Set doc2 = Documents(2) |
Else |
Set doc1 = Documents(2) |
Set doc2 = Documents(1) |
End If |
If doc1.Pages.Count > doc2.Pages.Count Then |
doc2.AddPages doc1.Pages.Count - doc2.Pages.Count |
End If |
For Each p In doc1.Pages |
p.Activate |
p.Shapes.All.Copy |
doc2.Pages(p.Index).Activate |
doc2.ActiveLayer.Paste |
Next p |
doc2.Activate |
End Sub |
Copyright 2013 Corel Corporation. All rights reserved.