OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   Select Shape after Undo... (http://forum.oberonplace.com/showthread.php?t=24601)

FaneDuru 28-02-2013 05:02

Select Shape after Undo...
 
I have a GMS file preparing a file for cutting. I treat some cases (powerClip, Group or simple lines nets) and during fine tuning I need to revert at the initial selection. For the cutting shape belonging to a group I try to select it again after Undo (programmatically), but it does not work...
I know the shape name and I use the next code:
Code:

Private Sub btUndo_Click()
    Application.Optimization = True
        ActiveDocument.Undo
    Application.Optimization = False
    ActiveWindow.Refresh
    Application.Refresh
    Prnt.Activate
    Prnt.Shapes("xxx").CreateSelection
End Sub

I also tried:
Code:

Prnt.Shapes.FindShape("xxx").CreateSelection
but it does not work
'Prnt' is the page where the group is, declared at the form class level and it is not nothing...
I mean this code put exactly instead of the line to create selection:
Code:

Debug.Print Prnt.Shapes("xxx").Name
returns 'xxx'.
I can select the specific shape in a separate piece of code but not after Undo...
I tried also to put those lines in a separate procedure and call it but the same result...

Are there some limitations after using Undo?
How can a I select that shape after Undo?


I use CorelDRAW X5.

Thanks in advance!

FaneDuru 28-02-2013 08:19

In the meantime I did the next tests:
This simple code can be UNDO with shape selection:
Code:

Sub testSelForUNDO()
  Dim S As Shape
  ActiveDocument.BeginCommandGroup "CreareRect"
    Set S = ActivePage.ActiveLayer.CreateRectangle(50, 200, 22, 20)
    'ActiveDocument.AddPages (1)
  ActiveDocument.EndCommandGroup
  ActiveWindow.Refresh
End Sub
Sub UndoWithSelection()
  ActiveDocument.Undo
  ActivePage.Shapes.FindShape("xxx").CreateSelection
End Sub

With the line adding a new page (commented now), it does not select the shape any more...
I also mention that the shape in discussion is part of a group but I do not think that can be a problem. FindShape works inside groups, too...

I also mention that this is not an issue which I really need but I would like to understand what happens and how it can be solved...
I can see that the shape (xxx) looks selected in Object Manager. If in 'UndoWithSelection' procedure I insert a line:
Code:

Debug.Print ActiveShape.BottomY
it returns the real bootomY of the shape like selection exists...
If I put this line in another procedure and run it returns an error message (Object variable or With block variable not set), like anything is selected.
I tried ActiveWindow.Refresh, but without result.

What else should I try?

ddonnahoe 01-03-2013 07:24

Have you tried setting the active selection to a variable at the beginning of the code run?
Code:

Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange


FaneDuru 01-03-2013 11:51

Firstly thanks for your wish to help me!

I am not sure I understand what you mean... To use that in the procedure involving Undo and my intention to select the shape (part or a group)?
If yes, I tried it now without success...
I also tried to declare it like a public shape at the class level and even if referencing it is good and the shape is not nothing it can not be selected.
Can you use your suggestion in the small example I posted?
I would like to mention that during the procedure involving Undo the selected shape is clearly identified and I am able to clone, copy, whatever can be done with a shape but not select it. Only inside this procedure... It appears to be selected for a moment and immediately is deselected... It just does not look like being selected (except in Object Manager) and it is not selected at all in order to be recognized as active shape in a future procedure...


All times are GMT -5. The time now is 17:28.

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