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 25-05-2008, 06:38
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 430
Default Problem copying text and

Hello, I'm trying to copy some text to the clipboard, adding additional text in the process. The problem I have is that CorelDraw is pasting extra carriage returns. Here is some example code in progress I'm using:

Code:
Sub makecode()

Dim t As Shape
Dim l As Integer
Dim pn As String

l = 1

pn = ActiveShape.text.Story.Lines(l).Words.First


pn = "SetLabel " & pn & " EndLabel"

Set t = ActivePage.ActiveLayer.CreateParagraphText(0, 0, 4, 4, pn, , , "Times New Roman", 24, cdrTrue, cdrTrue, , cdrLeftAlignment)
t.text.Story.Copy
t.Delete

MsgBox "Finished"
This pastes the first line of my selected text object to the clipboard. However it is pasting:

SetLabel pn
EndLabel

Rather than:

SetLabel pn EndLabel

How can I stop Draw adding the carriage return. I tried using pn = trim(pn) but that made no difference.

Thanks,

Chris (Hunt)
Reply With Quote
  #2  
Old 25-05-2008, 08:43
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 430
Default Left is the solution

Hello I think I found the solution - use left to strip away the carriage return, though I still don't get why it is there in the first place:

Code:
pn = Left(pn, Len(pn) - 1)
Chris (Hunt)
Reply With Quote
  #3  
Old 25-05-2008, 21:12
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

It is there because that's the way CorelDRAW selects words. When you select a word, all the characters of that word are selected along with all the following non-word characters such as whitespaces, commas, periods, and carriage returns.

Try double-clicking a word in CorelDRAW and see what gets selected.

Now in order to fix this, you can delete the carriage return character by doing this:

Code:
Replace(pn, vbCr, "")
Reply With Quote
  #4  
Old 25-05-2008, 22:15
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 430
Default

Thanks Alex, I tried the code you suggested but I keep getting a compile error "wrong number of arguments or invalid property assignment". There's another recent thread ("Problems with replace") where I mentioned the same problem and Shelby suggested adding p.activate. It's as if ordinary vba replace doesn't work.

Chris
Reply With Quote
  #5  
Old 27-05-2008, 18:14
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Show me the code that doesn't compile.. I'm sure you are doing something wrong. VBA Replace function does work. I use it all the time...
Reply With Quote
  #6  
Old 27-05-2008, 19:44
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 430
Default

Quote:
Originally Posted by Alex View Post
Show me the code that doesn't compile.. I'm sure you are doing something wrong. VBA Replace function does work. I use it all the time...
Hi Alex, I posted an example in the Problems with replace thread. Here's another one showing the code I'm trying to use. I just tried it and got the same error message:

Code:
Sub replaceTest()

Dim s As Shape

For Each s In ActivePage.Shapes

    s.Name = replace(s.Name, "a", "z")

Next s

End Sub
Thanks,

Chris
Reply With Quote
  #7  
Old 28-05-2008, 07:47
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Try changing "Dim s As Shape" into "Dim s As CorelDRAW.Shape"
Reply With Quote
  #8  
Old 28-05-2008, 08:01
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 430
Default

Hi Alex, I still get the same error.

Chris
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
Striping a word down to the first letter only knowbodynow CorelDRAW/Corel DESIGNER VBA 9 19-04-2007 15:14
Problem with pasting Word text into Corel Draw fotis CorelDRAW/Corel DESIGNER VBA 2 22-06-2006 01:59
text node problem mudhen General 3 17-07-2005 11:01
Corel12 - Text case problem sherman01 CorelDRAW/Corel DESIGNER VBA 4 11-02-2005 09:37
Text selection problem ken_ac CorelDRAW/Corel DESIGNER VBA 2 10-02-2004 20:24


All times are GMT -5. The time now is 22:05.


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