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 23-09-2007, 00:16
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default Problem with Words

Hello,

I'm trying to create some code that will check for the presence of a particular word in a text string and colour particular letters of the word if it is found. Here is the code that I thought would work:

Code:
Sub wordtest()

Dim sh As Shape
Dim w As Integer

Set sh = ActiveShape

If sh.Type = cdrTextShape Then
    
w = 1

While sh.text.Story.Words.Count + 1 > w
   
If sh.text.Story.Words(w) = "bang" Then
  sh.text.Story.Words(w).Range(2, 3).Fill.UniformColor.CMYKAssign 20, 80, 0, 40
  sh.text.Story.Words(w).Range(3, 4).Fill.UniformColor.CMYKAssign 20, 80, 0, 40
End If
    
If sh.text.Story.Words(w) = "camel" Then
  sh.text.Story.Words(w).Range(3, 4).Fill.UniformColor.CMYKAssign 0, 20, 20, 50
End If
     
w = w + 1
Wend
    
End If

End Sub
But this only colours the last word, so if I have a string "camel bang" the bang is coloured but not camel. What have I done wrong?

Thanks,

Chris
Reply With Quote
  #2  
Old 23-09-2007, 00:39
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,778
Blog Entries: 11
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 Add a space

When it finds camel it adds the space on the end, so in your IF THEN use "camel "

-Shelby
Reply With Quote
  #3  
Old 23-09-2007, 01:35
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default

Hi Shelby, why does it add a space? Anyway, you helped me to find the answer which is to use trim. E.g:

Code:
If Trim(sh.text.Story.Words(w)) = "camel" Then
  sh.text.Story.Words(w).Range(3, 4).Fill.UniformColor.CMYKAssign 0, 20, 20, 50
    Qt = 1
End If
Thanks,

Chris
Reply With Quote
  #4  
Old 23-09-2007, 01:37
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,778
Blog Entries: 11
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 No Idea

I have no idea why the space in included. I work very little with text and VBA, just know that is the issue.

-Shelby
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
Problem using "GetUserClick" with Snap? Jon Lorber CorelDRAW/Corel DESIGNER VBA 3 12-06-2006 11:47
Problem with VBA in Draw X3 LGD CorelDRAW/Corel DESIGNER VBA 8 19-01-2006 09:14
CD11 Convert to Bitmap -> CMYK to Gray scale problem xenio General 7 24-07-2005 21:46
StructSaveAsOptions problem gpf CorelDRAW/Corel DESIGNER VBA 3 11-01-2005 22:19
Problem with Export (or Save as) in AI-Format LOT CorelDRAW/Corel DESIGNER VBA 3 10-02-2004 14:28


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


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