OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Thread Tools Search this Thread Display Modes
Old 19-01-2004, 23:21
Posts: n/a
Default Paragraph text like Ingredient List

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?
Reply With Quote
Old 20-01-2004, 00:20
Alex's Avatar
Alex Alex is offline
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default Re: Paragraph text like Ingredient List

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:

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
11. Now run the macro. You will have a nicely formatted list of ingredients.

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.
Attached Images
Reply With Quote
Old 22-01-2004, 21:59
Posts: n/a

Thank you very much Alex!
Reply With Quote

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
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

All times are GMT -5. The time now is 15:46.

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