![]() |
#1
|
|||
|
|||
![]()
I have another question about text. Is it possible to use vba to add a specific text string to every artistic text object on a particular layer? I'd like to be able to add txg to the end of every piece of text. The reason is if I can add txg then when I centre the text it will centre as text on the page. Without adding a string text missing an ascender or descender will not line up correctly. Once hte text is centred I can then do a search and replace and remove txg leaving me with correctly positioned text.
Chris (Hunt) |
#2
|
||||
|
||||
![]()
Here is the code to go through all text objects on the current layer and add "txg" at the end:
Code:
Sub AddTXG() Dim s As Shape For Each s In ActiveLayer.Shapes.FindShapes(Type:=cdrTextShape) s.Text.Story.InsertAfter "txg" Next s End Sub Code:
Sub RemoveTXG() Dim s As Shape Dim tr As TextRange For Each s In ActivePage.Shapes.FindShapes(Type:=cdrTextShape) If Right(s.Text.Story, 3) = "txg" Then Set tr = s.Text.Story.Duplicate() tr.Start = tr.End - 3 tr.Delete End If Next s End Sub |
#3
|
|||
|
|||
![]()
Thanks Alex, that's just what I asked for. I've just finished testing an alternative solution which seems to work for what I have in mind. Since I didn't know how to insert text I figured out a way to temporarily change the vowels:
s.Text.Replace "a", "1tag1", True, ReplaceAll:=True s.Text.Replace "e", "2teg2", True, ReplaceAll:=True s.Text.Replace "i", "3tig3", True, ReplaceAll:=True s.Text.Replace "o", "4tog4", True, ReplaceAll:=True s.Text.Replace "u", "5tug5", True, ReplaceAll:=True s.AlignToPageCenter cdrAlignHCenter + cdrAlignVCenter, cdrTextAlignBoundingBox s.Text.Replace "1tag1", "a", True, ReplaceAll:=True s.Text.Replace "2teg2", "e", True, ReplaceAll:=True s.Text.Replace "3tig3", "i", True, ReplaceAll:=True s.Text.Replace "4tog4", "o", True, ReplaceAll:=True s.Text.Replace "5tug5", "u", True, ReplaceAll:=True Needless to say your way leaves my homespun method flapping in the mud. I've only just joined today and I've receive brilliant advice. It must be brilliant because I think I can understand and use it! Thanks again, 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 |
Adding a button to toolbars to run a VBA macro | Alex | FAQ | 4 | 10-05-2007 08:07 |
Text selection and sizing | ddonnahoe | CorelDRAW/Corel DESIGNER VBA | 5 | 17-05-2005 13:19 |
format text dialog box implement | graphicdesigner | CorelDRAW/Corel DESIGNER VBA | 5 | 22-12-2004 13:37 |
Reset text after text compression. | Bellekom | CorelDRAW/Corel DESIGNER VBA | 2 | 05-05-2004 06:14 |
Create text in PP with VBA | adriano | Corel Photo-Paint VBA | 1 | 07-01-2003 17:09 |