OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   Optimization and phantom object (http://forum.oberonplace.com/showthread.php?t=24783)

ager 15-03-2017 23:43

Optimization and phantom object
 
If you execute this code for any group shapes:
Code:

Dim sr As ShapeRange
Set sr = ActiveSelectionRange
If sr.Shapes.Count < 1 Then Exit Sub
Optimization = True
    sr.Ungroup
    sr.Shapes(1).Delete ' or do something else with the shapes
    ActiveSelection.Group
Optimization = False: ActiveWindow.refresh

the phantom object appears in the Object Manager:
http://s020.radikal.ru/i714/1703/ac/e3474bff4a3f.png
I can't select this object, can't delete it. Is this a bug or not?

shark 16-03-2017 08:09

It's all because of the optimization is enabled. Without it everything is working fine

ager 16-03-2017 21:32

Yes, of course. Without optimization it's working fine. But if I'm deal with quite complex group consisting of many shapes the optimization is extremely desirable

shark 17-03-2017 02:00

Try using ActiveDocument.BeginCommandGroup/EndCommandGroup instead of Optimization. This also speeds up the execution of the macros

Funny turns out, two Russian-speaking people communicates in English at a foreign forum :)

ager 17-03-2017 06:29

Thank you Shark for the answers (greetings from Siberia :) )!
Begin/EndCommandGroup helps a little. In some cases adding "EventsEnabled=True/False" can help, but phantom objects can appear again.

shark 17-03-2017 08:18

I wondered why I had never encountered such a bug before. And I realized...

Change ActiveWindow.refresh to Refresh

ager 18-03-2017 02:29

Amazing! It works! I would never have guessed. Thanks Shark


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

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