![]() |
#1
|
|||
|
|||
![]()
I have a routine that automatically renames pages. Later I use the page name as the name for a file containing an exported graphic. However, I've discovered a problem if the text I use has extra paragraph returns at the end. This messes up the page name and later causes my export to fail. I want to remove the paragraph marks. I've tried:
Code:
Dim p As Page Dim s As Shape For Each p In ActiveDocument.Pages For Each s In p.ActiveLayer.FindShapes(Type:=cdrTextShape) Replace(s.Text.Story, Chr(182), "") p.Name = Trim(s.Text.Story) Next s Next p Thanks, Chris (Hunt) |
#2
|
||||
|
||||
![]()
Chris,
First, to start, a new paragraph mark is represented as a character with code 10, that is, Chr(10), or using predefined VBA's constant vbLf, and not the paragraph sign, Chr(182). Well, this is valid for Paragraph Text only. In Artistic Text object, new line start with character 13, or vbCr for short. This is the same character as soft line return (Shift-Enter) in Paragraph text, because essentially a artistic text object is one single paragraph of text... The problem number two is that you can't just do something like this: Code:
Replace(s.Text.Story, Chr(182), "") Code:
s.Text.Story = Replace(s.Text.Story, vbCr, "") Code:
Sub RenamePage() Dim strText As String If ActiveShape Is Nothing Then Exit Sub If ActiveShape.Type <> cdrTextShape Then Exit Sub strText = ActiveShape.Text.Story strText = Replace(strText, vbCr, "") ' Remove soft returns strText = Replace(strText, vbLf, "") ' Remove paragraph breaks strText = Trim(strText) ' Remove any space in front/at the back of the text ActivePage.Name = Left(strText, 32) ' Use no more than 32 characters End Sub |
#3
|
|||
|
|||
![]()
That's great, Alex. You make it very clear and usable. Since I started using VBA CorelDraw has become twice the program - thanks to you.
Best wishes, Chris |
![]() |
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 |
Striping a word down to the first letter only | knowbodynow | CorelDRAW/Corel DESIGNER VBA | 9 | 19-04-2007 15:14 |
Paragraph Text in Photo-Paint? | CgNeophyte | General | 1 | 11-04-2006 18:16 |
corelDRAW paragraph text mirror "bug" | hellraeser | General | 2 | 08-03-2006 23:17 |
Rotating multiple artistic text objects | geopig | CorelDRAW/Corel DESIGNER VBA | 6 | 01-03-2005 16:51 |
Artistic Text or paragraph invisible after upgrade to v11 ?? | tuxedo21 | CorelDRAW/Corel DESIGNER VBA | 0 | 26-08-2003 16:27 |