![]() |
#1
|
|||
|
|||
![]()
All,
Is there a way to find/replace all shapes with the same name in CorelDRAW 10? I am importing multiple documents (actually the same document multiple times) into 1 document - thus duplicating the shape names that I need to change. The first shape it comes to gets the replace - the rest are left their original value. Thanks much, Craig... |
#2
|
||||
|
||||
![]()
Craig,
Have you tried to use Page.FindShapes method? It can return a list of shapes matching your criteria. You can specify the name to look for and it will return you a list of shapes with the same name. Then you can just loop through them: Code:
Dim s As Shape For Each s In ActivePage.FindShapes("YourShapeName") ' Process the shape "s" here Next s |
#3
|
|||
|
|||
![]()
Oh thanks a ton Alex - Exactly what I needed!
Craig... |
#4
|
|||
|
|||
![]()
Hi Alex,
I finally got around to this and I can't seem to get it to work... Just a reminder that I'm still in V10... Here's my current code Set s = mPage.ActiveLayer.FindShape(lcLookFor) If lbIsLogo = False Then If Not s Is Nothing Then s.Text.Contents = lcReplace I tried pulling out the "Set s" and replacing with (and other combinations) Dim s As Shape For Each s In mPage.ActivePage.FindShapes(lcLookFor)... but kept getting the object/property doesn't support... error on s.Text.... Any help would be appreciated... Thanks, Craig... |
#5
|
||||
|
||||
![]()
It means that you are finding shapes other than text. For example, one of your rectangles might be named the same way and you are picking it up. Obviously, s.Text.... won't work on a rectangle, or ellipse, or curve, etc.
Either fix your drawing to make sure that only text objects bear the name you are looking for, or add a check for text shapes: Code:
Dim s As Shape For Each s In ActivePage.FindShapes(lcLookFor) If s.Type = cdrTextShape Then s.Text.Contents = lcReplace End If Next s |
#6
|
|||
|
|||
![]()
Hi Alex,
I get a compile error: Method or data member not found on .Text CT... Dim s As Shape For Each s In ActivePage.FindShapes(lcLookFor) If lbIsLogo = False Then If Not s Is Nothing Then s.Text.Contents = lcReplace |
#7
|
|||
|
|||
![]()
Hi Alex,
I get "Method or Data Member Not Found" -> If s.Type on compile with your sample... Code:
Dim s As Shape For Each s In ActivePage.FindShapes(lcLookFor) If s.Type = cdrTextShape Then s.Text.Contents = lcReplace End If Next s Code:
Set s = mPage.ActiveLayer.FindShape(lcLookFor) If lbIsLogo = False Then If Not s Is Nothing Then s.Text.Contents = lcReplace If s.Text.Type = cdrParagraphText And lbFTTF = True Then Craig... |
#8
|
||||
|
||||
![]()
Craig,
I don't know why you have a problem with my original code. Here is a new one which I just tested on my CorelDRAW 10.427. Just create a few text objects and give them name "Label" through Object Manager. Then run the following: Code:
Sub ReplaceAllText() Const sNameToLookFor As String = "Label" Const sTextToSet As String = "Label #" Dim nLabelID As Long Dim s As Shape nLabelID = 1 For Each s In ActivePage.FindShapes(sNameToLookFor, cdrTextShape) s.Text.Contents = sTextToSet & nLabelID nLabelID = nLabelID + 1 Next s End Sub There are two methods on Page - FindShape which returns the first object found; and FindShapes which returns a ShapeRange object, that is a list of all shapes found. You can iterate through them using For Each...Next as I showed in my above example. In the code above I not only look for objects by name, but also by object type - particularly for text objects only, so I don't need to add another test to see the type of the object found to ensure it is a text. I hope this helps... |
#9
|
||||
|
||||
![]()
Craig,
On another thought, do you use VBA or stand alone Visual Basic. The thing is that VB has it's own Shape object, that is a form control which can look like a circle, rectangle, etc. So you end up with two Shape objects - one from VB and one from CorelDRAW and because VB type libraries are listed first in the References dialog, VB uses the form shape by default. To resolve ambiguity, you can either go to References dialog and move CorelDRAW type library higher in the list, or just specify CorelDRAW type library explicitly when declaring the variable: Code:
Dim s As CorelDRAW.Shape |
#10
|
|||
|
|||
![]() Code:
Dim s As CorelDRAW.Shape |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
a shape on top of another | Seelenquell | CorelDRAW/Corel DESIGNER VBA | 15 | 01-03-2008 08:08 |
Moving Shape to another page using C++ | moodwin | CorelDRAW/Corel DESIGNER VBA | 4 | 18-03-2005 02:01 |
Howto uniquely identify a shape in VBA code | jemmyell | CorelDRAW/Corel DESIGNER VBA | 9 | 11-02-2005 21:05 |
Getting the center X on a text shape | Rick Randall | CorelDRAW/Corel DESIGNER VBA | 4 | 03-08-2004 18:27 |
finding node angles? | IanVincent | CorelDRAW/Corel DESIGNER VBA | 4 | 12-12-2003 23:32 |