OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Corel User Forums > Corel PHOTO-PAINT > Macros/Add-ons

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 28-09-2008, 04:50
cooloox
Guest
 
Posts: n/a
Default Macro to hide all but the selected object

Hi everyone,
this is my first time posting or even visiting here. I have made a simple vba macro in Photo-Paint to hide all but the active object (layer). It seemed to run fine until Jeff Harrison picked up on a little glitch. If I open a document which has several objects and/or I create some objects - the macro will happily let me hide all objects except the one currently selected. However, if I combine 2 objects the macro simply will not recognise the new combined object as an object. I have to save and close the file and reopen it again for the macro to recognise the object.
Does anyone have any idea why this may be happening? My code for hiding all but the selected object is as follows:

Private Sub HideABS_Click()
On Error Resume Next
Set LR = ActiveDocument.Layers.All
Set AL = ActiveDocument.ActiveLayer
For Each L In LR
L.Visible = False
Next L
AL.Visible = True

End Sub
Best regards,
Brian.

Last edited by cooloox; 28-09-2008 at 05:05.
Reply With Quote
  #2  
Old 28-09-2008, 20:15
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
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 Layers...

It looks like the Layers list is not being updated after the merge. So when you run your code, it is still working off the old list of layers. That is why you need the On Error, because it then tries to reference a Layer that no longer exists. And it can't see the new merge Layer you just created.

Unfortunately this looks to be a bug, and I don't see a way to refresh it.

-Shelby
Reply With Quote
  #3  
Old 28-09-2008, 22:19
cooloox
Guest
 
Posts: n/a
Default

Thanks for your comments, Shelby. I feared this was the case and you just confirmed it. Even closing the macro (unloading it from memory) does not fix the issue; when restarting the macro the new object is still not recognised.

Saving the file, closing it and reopening it is the only way to get things working properly again. Just one other comment: I even renamed the combined object to one of the original object's names and it was still not recognised. It is as though an object created by combining others is no longer recognised as an object by VBA. Maybe if the objects are combined using VBA the resultant object will be recognised. I will have to experiment further.

Thanks again for your reply,
Brian.
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
Macro for Object Nesting? excessiveforce New product ideas 9 31-05-2010 01:12
Selected object to other page Duplicate method ? ljesus7 CorelDRAW/Corel DESIGNER VBA 5 12-02-2007 17:37
Macro to Delete Leading Zeros in selected shapes (dimensions) Jon Lorber CorelDRAW/Corel DESIGNER VBA 1 18-05-2006 13:25
Hide/ Show Toolbars ivelink CorelDRAW/Corel DESIGNER VBA 1 23-06-2005 12:17
Retrieve Color Values from Selected Object Jon Lorber CorelDRAW/Corel DESIGNER VBA 2 19-08-2004 08:24


All times are GMT -5. The time now is 04:39.


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