OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Thread Tools Search this Thread Display Modes
Old 12-12-2012, 05:03
vavalexus vavalexus is offline
Junior Member
Join Date: Sep 2012
Location: Ukraine
Posts: 5
Default Wildcard for a text find

Hello there!

I have a macro wich searches for particular block names specified in a text filed in a form.
For example I have block names:
  • Electrics 220V,
  • Electrics 380V,
  • Water
  • Phone
In the text field I can input name and Wildcard (* or ?). So for example: Elec* search will return all blocks with names starting as "Elec". I have search all the Internet over in search of extended wildcards as OR and AND. So I need to add a criteria for a search: Elec* OR Wat* so it will find those names.
If I just put * it will find all blocks.
Of cause I can add another text field and put Wat* there but I can have many of such criteria and the best way to have a single text field for a search.

Any ideas?
Reply With Quote
Old 21-12-2012, 13:52
shelbym's Avatar
shelbym shelbym is offline
Senior Member
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,788
Blog Entries: 12
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 Wildcard for a Text Find

I think the easiest way to do this would be to split your string by a delimiter and then pass each word to your search function. Here is a little example:
Sub FindText()
    Dim strMyString As String
    Dim i As Integer
    Dim vArray As Variant
    Dim srFoundText As New ShapeRange
    strMyString = "Elec OR Wat"
    vArray = Split(strMyString, " OR ")
    For i = 0 To UBound(vArray)
        srFoundText.AddRange FindTextCQL(vArray(i))
    Next i
    srFoundText.ApplyUniformFill CreateCMYKColor(0, 100, 100, 0)
End Sub
Here is my search function that returns a shaperange with the found shapes. It uses CQL to find the text shapes which contain the partial word.
Private Function FindTextCQL(ByVal strFind As String) As ShapeRange
    Set FindTextCQL = ActivePage.Shapes.FindShapes(Query:="@type ='text:artistic' or @type ='text:paragraph' and @com.text.story.text.contains('" & strFind & "')")
End Function
So as you can see, we just take the string and split on the " OR " and then pass each word. All found text shapes are then filled red.

Reply With Quote
Old 24-12-2012, 11:29
vavalexus vavalexus is offline
Junior Member
Join Date: Sep 2012
Location: Ukraine
Posts: 5

Dear Shelby!

Thank you for the tip. I will try to use it.
Since I'm not a sophisticated VBA code writer I simply used further commands:

Dim Nme As String
Nme = Sym_name.Value
If AllShapes(i).Symbol.Definition.Name Like Nme Then
ActiveSelection.CopyToLayer ActivePage.Layers("Tech service copy")
End If
I didn't know how to process this entry filed for several strings. I could only suggest making another field (but such fields could be more then two).
So you gave me a great idea and thank you for that!

Merry Christmas!
Reply With Quote
Old 27-12-2012, 10:53
vavalexus vavalexus is offline
Junior Member
Join Date: Sep 2012
Location: Ukraine
Posts: 5
Default Wildcard for a text find

OR comand turned to be easy, in my case I didn't need the function.
With your help I wrote:

Dim Nme As String
Dim vArray As Variant
Nme = Sym_name.Value 'search words
vArray = Split(Nme, " OR ")
Set AllShapes = ActivePage.Layers.Item("Tech services").Shapes.All
For j = 0 To UBound(vArray)
For i = 1 To AllShapes.Count
If AllShapes(i).Type = cdrSymbolShape Then
If AllShapes(i).Symbol.Definition.Name Like vArray(j) Then
AllShapes(i).CopyToLayer ActivePage.Layers("Tech service copy")


Now I'm heaving a headache with AND comand. It turnes to be more complicated.
For now I manage to find groups of symbols in each shape. And I need to check if both A and B symbols are in the shape.
First cycle would contain search words, second one - symbols withing each shape. Can't figure out how to search both symbols. Maybe to group all symbol names withing one shepe into a single string, then to search in the string for both A and B names... Any ideas?
Reply With Quote
Old 14-01-2013, 04:01
vavalexus vavalexus is offline
Junior Member
Join Date: Sep 2012
Location: Ukraine
Posts: 5

I have done it. It was much harder then OR operation.
Reply With Quote

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
CQL does not find text shapes aakkaarr CorelDRAW/Corel DESIGNER VBA 1 12-05-2011 09:40
Find and replace text, and only changed the Scale pithe CorelDRAW/Corel DESIGNER VBA 8 20-01-2011 15:47
FInd index of shapes grouped with text rubidoux CorelDRAW/Corel DESIGNER VBA 3 07-10-2007 23:00
Find all text and apply text style keytecstaff CorelDRAW/Corel DESIGNER VBA 2 18-05-2006 10:48
Find and Replace Text with Form RVogel CorelDRAW/Corel DESIGNER VBA 1 24-03-2005 10:37

All times are GMT -5. The time now is 18:20.

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