OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 30-06-2008, 15:54
sakis_drm
Guest
 
Posts: n/a
Red face Corel's bug?

Seems like Corel's bug..

If anyone has any idea or
If anyone faces the same problem or
If anyone has solved thar problem in the past,

It would be great to post his opinion..
Reply With Quote
  #3  
Old 30-06-2008, 21:53
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 10
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default CopyToNextPage

Alright I have only tested this in X4, but I think it does everything you want. It takes the selection, creates a new page and moves a duplicate of the selection to the new page. It then applies a yellow fill to each of the new shapes on the new page. The original page is left intact with no changes.
Code:
Sub CopyToNextPage()
    Dim s As Shape
    Dim sr As ShapeRange
    Dim p As Page
    
    Set sr = ActiveSelectionRange.Duplicate() 'Duplicate the selection
    Set p = ActiveDocument.InsertPages(1, False, ActivePage.Index) 'Create a new Page
    
    sr.MoveToLayer p.Layers("Layer 1") 'Move the duplicates to the new page
    
    'Do something to the duplicates (Fill them Yellow)
    For Each s In sr
        s.Fill.ApplyUniformFill CreateCMYKColor(0, 0, 100, 0)
    Next s
End Sub
What did I miss?

-Shelby
Reply With Quote
  #4  
Old 01-07-2008, 14:59
sakis_drm
Guest
 
Posts: n/a
Default Need a real page activation

Thanks for you response,

my original issue is the same because if i add the line...
Quote:
MsgBox ActiveDocument.ActivePage.Name
at the end of your code ... It will return "Page 1" again!

In your code "CopyToNextPage" you refear to an object "SR".
In my code I reafer to activepage's objects. That is the difference...

I need a command that will realy activates the newly created page..
something like...

1. Add a page
2. Activate that new page
3. MsgBox ActiveDocument.ActivePage.Name
4. must return the new page's name

Thanks a lot.
Reply With Quote
  #5  
Old 01-07-2008, 16:03
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 10
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Version

***Update: I have now tested in 12 and X3 and I get the same results: Page1, Page2, Page2 as expected

What version are you using? I tried the following code in X4 SR1
Code:
Sub CopyToNextPage()
    Dim s As Shape
    Dim sr As ShapeRange
    Dim p As Page

    MsgBox ActiveDocument.ActivePage.Name
    
    Set sr = ActiveSelectionRange.Duplicate() 'Duplicate the selection
    Set p = ActiveDocument.InsertPages(1, False, ActivePage.Index) 'Create a new Page
    
    p.Activate
    MsgBox ActiveDocument.ActivePage.Name
    
    sr.MoveToLayer p.Layers("Layer 1") 'Move the duplicates to the new page
    
    'Do something to the duplicates (Fill them Yellow)
    For Each s In sr
        s.Fill.ApplyUniformFill CreateCMYKColor(0, 0, 100, 0)
    Next s
    
    MsgBox ActiveDocument.ActivePage.Name
End Sub
And it reports: Page1, Page2, Page2 as I would expect.

-Shelby

Last edited by shelbym; 01-07-2008 at 16:21. Reason: Tested is 12 and X3
Reply With Quote
  #6  
Old 02-07-2008, 11:36
sakis_drm
Guest
 
Posts: n/a
Default Does not activate page 2

I got "Page 1", "Page 1", "Page 1" on Corel version 14.0.0.567

I ll try to update my version if i can

The only way to get "Page 2" is to place a breakpoint on the last msgbox command.
Maybe I have to do that in 2 steps to force the user to press another button
in order to execute the procedures to the newly created page after the page activation.
Reply With Quote
  #7  
Old 02-07-2008, 12:54
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Have you installed the service pack for CGS X4? If not, you should

http://www.corel.com/servlet/Satelli...=1205332430735
Reply With Quote
  #8  
Old 02-07-2008, 16:02
sakis_drm
Guest
 
Posts: n/a
Default Alex is right

Service Pack 1 solved that issue.

Alex and Shelbym, thanks a lot!
Nice to meet you!
Reply With Quote
Reply

Tags
activate, breakpoint, page, paste


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Import Page Only bprice CorelDRAW/Corel DESIGNER VBA 4 11-06-2008 06:03
Duplicating original page for multi-page layout psypha General 1 06-08-2007 14:05
Problem with Page Numbering macro pmills Macros/Add-ons 1 07-05-2005 08:49
why can not do two pagenumbering in one page? olympiatr CorelDRAW/Corel DESIGNER VBA 2 20-10-2004 03:09
Page Numbering Hernán CorelDRAW/Corel DESIGNER VBA 3 11-06-2004 02:25


All times are GMT -5. The time now is 16:48.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com