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 08-02-2008, 16:16
m31uk3
Guest
 
Posts: n/a
Default Get Shape Index ID Value

Hello I did my best to search the site as this seems simple.

I want to act on the Index ID of a specific shape.

For instance the following.

Code:
Dim s As Shape
For Each s In ActivePage.Shapes
    MsgBox s.Item.Index.Value
Next s
I want this number...X

ActivePage.Shapes(X).Delete

Then I should be able to delete all Shape IDs which are >= 1 Or <= 11

Am I just not thinking?

Thanks!
Reply With Quote
  #2  
Old 08-02-2008, 16:28
Craig Tucker
Guest
 
Posts: n/a
Default Delete Shapes...

Hi,
It's been a while on this one but I think you might approach it like this.
HTH,
Craig...

Create a new ShapeRange
Code:
Dim lcDelShapeRange As New ShapeRange
Then when you come across a shape you want to delete,
Code:
For Each mShape In ActivePage.Shapes
   If mShape.Item.Index.Value >=1 And mShape.Item.Index.Value <=11
      lcDelShapeRange.Add ActivePage.Shapes(lcShapeName)
   End if
Next mShape
Lastly delete,
Code:
If lcDelShapeRange.Count Then
   lcDelShapeRange.Delete
End If

Last edited by Craig Tucker; 08-02-2008 at 16:48.
Reply With Quote
  #3  
Old 08-02-2008, 16:50
m31uk3
Guest
 
Posts: n/a
Default

Ok I just realized something that these id numbers change instantly so I wont be able to delete directly but rather add them to a shape range and then delete the range.
Reply With Quote
  #4  
Old 08-02-2008, 16:52
m31uk3
Guest
 
Posts: n/a
Default

Sorry I wasn't clear...

mShape.Item.Index.Value doesn't work I need to figure out how to retrive the ID from the Shape reference when parsing the ActivePage.Shapes object.
Reply With Quote
  #5  
Old 08-02-2008, 17:00
m31uk3
Guest
 
Posts: n/a
Default

Another question what is the difference between these statements?


ActivePage.Shapes.Item(1)
ActivePage.Shapes(2)
Reply With Quote
  #6  
Old 08-02-2008, 17:12
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Index is the default property of Shapes object. So writing Shapes(1) or Shapes.Item(1) is the same thing. VBA automatically calls Shapes.Item(1) when it sees Shapes(1)

If you want to delete the first 11 shapes of the collection you can do this:

Code:
Sub Delete11Shapes()
    Dim ss As Shapes
    Dim nCount As Long
    Dim i As Long
    Dim sr As New ShapeRange
    
    Set ss = ActivePage.Shapes
    nCount = ss.Count
    If nCount > 11 Then nCount = 11
    For i = 1 To nCount
        sr.Add ss(i)
    Next i
    sr.Delete
End Sub
Reply With Quote
  #7  
Old 08-02-2008, 19:50
m31uk3
Guest
 
Posts: n/a
Default

Cool that makes sense thanks very much.

But just so I understand can you get that number (Shape(ID)) and echo it with something like MsgBox? or is it strictly internal?
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
Symbol shape is not found in a group squonk CorelDRAW/Corel DESIGNER VBA 1 14-06-2007 07:32
CorelDRAW X3 VBA Code - Shape & Color LIster JudyHNM Code Critique 2 05-04-2007 15:02
Any idea what's wrong with this shape? jemmyell CorelDRAW/Corel DESIGNER VBA 4 08-05-2006 19:15
Automatically generate colour index numbers from 8-bit palet Jast New product ideas 3 07-07-2005 14:02
Howto uniquely identify a shape in VBA code jemmyell CorelDRAW/Corel DESIGNER VBA 9 11-02-2005 22:05


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


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