Hi all,
I have been working on a macro for a while that duplicates the current page and makes some changes to the objects.
But ideally I would like to expand on that and rename the page at the same time. But, what seems to happen is that I duplicate my current page as I would like to, and instead of working in the new page and renaming it, I stay with the original page and rename that one instead...
Sub proof_to_diagram()
'----------- main macro starts from here ---------------------- ActiveDocument.BeginCommandGroup "~page Dup and Hollow" 'need to have a duplicate of current page Call DuplicatePage("") 'work on second page ActiveDocument.Pages(2).Activate 'for older version of Corel 'rename this page as FD ActivePage.Name = "FD" 'need to change colors of all shapes on this page Call changeColors(ActivePage.Shapes.All) 'zoom to show all objects on the page ActiveWindow.ActiveView.ToFitAllObjects 'allow user to select dimension and form files through a user form UserForm1.Show ActiveDocument.EndCommandGroupEnd Sub
Function DuplicatePage(dummy) 'create a duplicate of current page Dim sr As ShapeRange Dim s As Shape Dim p As Page Dim i As Integer Dim oldPage As Page Dim srToSelect As ShapeRange Set srToSelect = ActivePage.Shapes.All srToSelect.RemoveRange ActiveDocument.MasterPage.Shapes.All 'ActiveDocument.Pages(0).Shapes.All srToSelect.CreateSelection
Set sr = ActiveSelectionRange Set oldPage = ActiveDocument.InsertPages(1, False, ActivePage.Index) ActiveDocument.Pages(2).Activate 'for older version of Corel ActivePage.SizeWidth = oldPage.SizeWidth ActivePage.SizeHeight = oldPage.SizeHeight ActiveDocument.DrawingOriginY = 6 For i = sr.Shapes.Count To 1 Step -1 Set s = sr.Shapes(i) s.Layer.Activate s.Duplicate s.MoveToLayer ActiveDocument.Pages(ActivePage.Index + 1).ActiveLayer Next i 'ActiveDocument.Pages(ActivePage.Index + 1).Activate Application.Refresh End Function
I feel like I just have the order of the steps mixed up a little but any help on this would be much appreciated.