![]() |
#1
|
|||
|
|||
![]()
I need to create text like this:
Tea .......................... 10.0 Sugar .......................... 20 Milk .......................... 0.03 Salt ............................. 40 Sodium Nitrate .......... 9761 I would like to automate this process. But I just cannot figure out how to determine number of dots between names and digits. What's paragraph text property I have to use? |
#2
|
||||
|
||||
![]()
Adding dots manually isn't the way to go. You need to set a tab stop somewhere at a proper position (e.g. 4 inches from the left margin) and specify that it is to be filled with dots (leadered). This is done in Format Text dialog.
Unfortunately tab stops are not accessible from VBA yet. So you will have to create a paragraph text style with properly formatted text including the tab stop and its attributes. Then when you create a paragraph text object through VBA, you just apply the style to it and all the formatting will be applied. Ok, here is what you need to do: 1. Open CorelDRAW and create a new document 2. Create an empty paragraph text object and type the text like "Tea<tab>10.0", where <tab> is just the tab key to be pressed. So the words "tea" and "10.0" are separated with a tab character 3. With the paragraph text selected click Ctrl-T to shoe the Format Text dialog 4. Go to the Tabs page of the dialog and clear all the preset tabs by the clicking the button on the lower right which looks like a page with red cross in it. 5. Then add one tab stop by clicking the "+" sign and set it to be at 4" from left, change the alignment to Right and put a checkmark in the Leadered column (see the attached screenshot for more information). 6. Apply the change to the text and close the dialog 7. Open the Graphics and Text style docker (Ctrl-F5) 8. Drag the text object and drop it onto the docker. This will create a new paragraph text style 9. Rename the style to, say, Ingredients. 10. Create the following VBA macro: Code:
Sub CreateIngredients() Dim sText As Shape Dim s As String s = "Tea" & vbTab & "10.0" & vbCrLf s = s & "Sugar" & vbTab & "20" & vbCrLf s = s & "Milk" & vbTab & "0.03" & vbCrLf s = s & "Salt" & vbTab & "40" & vbCrLf s = s & "Sodium Nitrate" & vbTab & "9761" Set sText = ActiveLayer.CreateParagraphText(0, 0, 4, 4, s) sText.ApplyStyle "Ingredients" End Sub Note that you can set font face, size, fill and other properties in the style, so you don't have to re-apply them after a new text object is created. This should do it for you. |
#3
|
|||
|
|||
![]()
Thank you very much Alex!
|
![]() |
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 |
Create Paragraph Text and Columns | bbolte | CorelDRAW/Corel DESIGNER VBA | 3 | 17-02-2005 21:43 |
Select Paragraph Text with more than one color | joexx | CorelDRAW/Corel DESIGNER VBA | 2 | 06-10-2004 12:20 |
Panic !!!!!! Paragraph text, frame height | Bellekom | CorelDRAW/Corel DESIGNER VBA | 4 | 11-05-2004 06:03 |
Resizing a Paragraph text box | Steege | CorelDRAW CS | 1 | 17-01-2004 04:24 |
Artistic Text or paragraph invisible after upgrade to v11 ?? | tuxedo21 | CorelDRAW/Corel DESIGNER VBA | 0 | 26-08-2003 16:27 |