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 15-03-2017, 23:43
ager ager is offline
Member
 
Join Date: Jul 2010
Location: Russia
Posts: 44
Default 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:

I can't select this object, can't delete it. Is this a bug or not?
Reply With Quote
  #2  
Old 16-03-2017, 08:09
shark shark is offline
Senior Member
 
Join Date: Aug 2010
Location: Russia, Belgorod
Posts: 146
Default

It's all because of the optimization is enabled. Without it everything is working fine
Reply With Quote
  #3  
Old 16-03-2017, 21:32
ager ager is offline
Member
 
Join Date: Jul 2010
Location: Russia
Posts: 44
Default

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
Reply With Quote
  #4  
Old 17-03-2017, 02:00
shark shark is offline
Senior Member
 
Join Date: Aug 2010
Location: Russia, Belgorod
Posts: 146
Default

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
Reply With Quote
  #5  
Old 17-03-2017, 06:29
ager ager is offline
Member
 
Join Date: Jul 2010
Location: Russia
Posts: 44
Default

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.
Reply With Quote
  #6  
Old 17-03-2017, 08:18
shark shark is offline
Senior Member
 
Join Date: Aug 2010
Location: Russia, Belgorod
Posts: 146
Default

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

Change ActiveWindow.refresh to Refresh
Reply With Quote
  #7  
Old 18-03-2017, 02:29
ager ager is offline
Member
 
Join Date: Jul 2010
Location: Russia
Posts: 44
Thumbs up

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


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
Optimization doesn't work while undoing. runflacruiser CorelDRAW/Corel DESIGNER VBA 4 23-06-2012 19:49
Positionin few object to few object VaaL2004 CorelDRAW/Corel DESIGNER VBA 1 10-10-2008 01:18
Optimization Vs. EventsEnabled ??? Rick Randall CorelDRAW/Corel DESIGNER VBA 8 19-03-2008 07:25
How to select object inside another object jukos General 4 24-10-2005 21:27
Optimization in CS fadimas CorelDRAW CS 0 08-05-2005 02:23


All times are GMT -5. The time now is 19:40.


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