View Single Post
  #1  
Old 22-06-2008, 07:57
sakis_drm
Guest
 
Posts: n/a
Default Mysterious problem in new page activation

I need to do some complex unrevertible tasks to the shapes of "original" Page 1.
e.g. continous break apparts, convert to curves etc...
and don't like to affect the shapes in the "original" Page 1.

So,
1. I copy the selected shapes
2. Create a new page "Page 2"
3. Activate "Page 2" (it is not mandatory to do this)
3. Paste them into "Page 2" (until that point, all works FINE)..

Now I have to do my tasks!
All the tasks are taking place at "Page 1" despite my activation on "Page 2"!!!

Code:
Public Sub CopyToNewPage()
    ActiveDocument.Selection.Copy
    ActiveDocument.AddPages 1
    ActiveDocument.ActiveLayer.Paste
    MsgBox ActiveDocument.ActivePage.Name
    'my tasks
End Sub

Now, watch carefully...
I have added a MessageBox that returns the active page's name...
It returns "Page 1"

If I put a breakpoint on the Paste or the Msgbox command,
after the resume
It returns "Page 2"


Note:
The same issue appears as well as to Shelbym's code which does the same work, posted somewhere into the forum.
I added the msgbox command.

Code:
Public Sub CopyToNext()
    Dim sr As ShapeRange
    Dim s As Shape
    Dim p As Page

    Set sr = ActiveSelectionRange
    Set p = ActiveDocument.InsertPages(1, False, ActivePage.Index)

    For Each s In sr
        s.Layer.Activate
        s.Duplicate
        s.MoveToLayer ActiveDocument.Pages(ActivePage.Index + 1).ActiveLayer
    Next s
    ActiveDocument.Pages.Last.Activate
    MsgBox ActiveDocument.ActivePage.Name

End Sub
I have tried to add commands in order to create an interval between the page creation paste... and my tasks such as:
  • DoEvents
  • TimePause (this is mine... it stops the system for a while)
  • Activewindow.Refresh

Last edited by sakis_drm; 22-06-2008 at 10:45.
Reply With Quote