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 31-01-2008, 20:52
bprice's Avatar
bprice bprice is offline
Member
 
Join Date: Oct 2006
Location: Edmundston, New Brunswick, Canada
Posts: 89
Default place text inside box with auto size?

question for everyone... am I dreaming... or is this possible? I have no problems creating a box... rectangle... whatever you'd like to call it, creating some paragraph text, and placing said paragraph text inside the box!

However, what i would like to ultimately have is a form/textbox that asks for some text, and no matter how much text I type, it will create a box AND paragraph text at a predefined width (it can't be more then say 30 characters wide for the paragraph text - wraps after 30 chars.).

So if I type 200 characters, it automatically will adjust the length of the box (object) and paragraph text accordingly! Possible... or is it a wonderful dream? haha

B
Reply With Quote
  #2  
Old 01-02-2008, 07:43
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

It's likely this can be done, but there are a lot of variables here that need to be determined. Depending on the font you use, 30 characters may be 1" wide at a certain point size and another font may be 3" at the same point size. Will you be using a mono-spaced font or variable? What point size is the text output at? Is 30 characters essential or just the actual measured width (ie. 1.36")?

There is an option in the Tools>Options>Workspace>Text>Paragraph... "Expand and Shrink..."
This option will increase or decrease the height of the frame to match the flow of text.

----------------
Now playing on Pandora: Slayer - Raining Blood
via FoxyTunes
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #3  
Old 01-02-2008, 09:39
bprice's Avatar
bprice bprice is offline
Member
 
Join Date: Oct 2006
Location: Edmundston, New Brunswick, Canada
Posts: 89
Default

well here's what I can tell you... I'll try and give you as much background as I can regarding what it is used for!

The text box belongs to a drawing template. We design signs, and we have a standard template that has boxes at a fixed width running down the right side of the page. They are description boxes that callout elements of the drawing. These boxes ALWAYS have the same width, but vary in height based on the amount of text we enter in our description. However, there are some things that always stay the same. The width obviously, and the font characteristics- Arial/Bold/9pt/Blue/All caps.

Currently we have a box that is a small bit larger then Arial Bold 9pt, with a 0.5pt black outline. It starts it's life out as box (in 1:1 scale) 2.843" w x 0.141" h. We type our text in the box (we simply have a "XX" artistic text sitting inside the box that we modify) and hit the return when it gets close to the edge of our box, and continue typing our description. Once we have typed all the text we need, we adjust our box in height, to match the height of the text we just typed! If we add another description, we duplicate the above text and box, and start the process all over again!

This has worded fine for years, but there has to be an easier way. That’s the reason I'd like to have everything automatic. I'd like a form to appear that I can type a description and it appears on the page, sized in height and (fixed) width automatically for whatever amount of text I typed in the textbox. Then if I wanted to add another item, it'd simply draw me a new box with the text inserted and sized directly under the first description. I've got that part all figured out... but I simply can't figure out the auto size feature!

I know it'd be easy if it was just the paragraph text on it's own, but I need to have the other box around it! Hence my reason for the post!

Thank you in advance for any and all help!

B
Reply With Quote
  #4  
Old 01-02-2008, 12:35
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

You could try this...
Code:
Sub Test() 
 Dim s As Shape 
 Dim s1 As Shape 
 Set s1 = ActiveLayer.CreateEllipse(0, 0, 2, 2) 
 Set s = ActiveLayer.CreateArtisticText(0, 0, "My Text", , , "Arial 
Black", 24) 
 s1.PlaceTextInside s 
End Sub
This code is directly from the help file, but you could modify it for your document.
Maybe have the box you want to input a description to selected already, then run a macro that offers the user a textbox to type in. Below is a sample of what I am talking about...
Code:
Sub InputDescription()
    Dim os As Shape, s As Shape, t As Text
    Dim desc As String
    If ActiveSelection.Shapes.Count < 1 Then
        MsgBox "Please select a box", vbOKOnly
        Exit Sub
    ElseIf ActiveSelection.Shapes.Count > 1 Then
        MsgBox "You must only have one box selected"
        Exit Sub
    End If
    
    Set os = ActiveShape
    desc = InputBox("Enter Description", "Description")
    If desc <> "" Then
        Set s = ActiveLayer.CreateParagraphText(0, 0, 1, 2.843, desc, , , "Arial", 9)
        Set t = s.Text
        t.Story.Case = cdrAllCapsFontCase 'This makes sure your output is ALLCAPS, just in case
        s.Fill.ApplyUniformFill CreateCMYKColor(100, 0, 0, 0)
        os.PlaceTextInside s
    End If
End Sub
This is all I have so far. I will work on having the box automatically reduce to fit the paragraph.

----------------
Now playing on Pandora: The Dillinger Escape Plan - Variations On A Cocktail Dress
via FoxyTunes
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #5  
Old 04-02-2008, 03:31
Gadget
Guest
 
Posts: n/a
Default

Quick questions:
1) Why does the paragraph box have to shrink at all? it can be the full height of the page - it's only the outline box that needs to end at a specific point and the next box down needs to start at a specific point.

2) Why can't you grow the box rather than shrink it? There is a flag on a paragraph box to say if it runs over, I'm sure some clever people could programatically check to see if it's active.

3) Why place the text inside the box? Why not draw the box to the size to match the text box?

Last edited by Gadget; 04-02-2008 at 03:33.
Reply With Quote
  #6  
Old 04-02-2008, 07:32
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

Unfortunately, my Kung-Fu is not that strong. I am sure that someone can expound on my previous macro to make it do those things. I will keep working on it, unless someone else posts and update to my code.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #7  
Old 05-02-2008, 10:49
Lev
Guest
 
Posts: n/a
Default

Code:
Sub Test()
 Dim s As Shape
 Dim s1 As Shape
 Set s1 = ActiveLayer.CreateEllipse(0, 0, 2, 2)
 Set s = ActiveLayer.CreateArtisticText(0, 0, "It is my very very very very very very long text", , , "Arial Black ", 24)
 Set s = s1.PlaceTextInside(s)
 While s.Text.Overflow
  s1.SizeWidth = s1.SizeWidth + 0.01
 Wend
End Sub
Note that this code can go into cycles for a multy string text because it changes only frame width while Overflow can be caused by more than 1 paragraph text.

Last edited by Lev; 05-02-2008 at 11:06.
Reply With Quote
  #8  
Old 08-02-2008, 05:56
bprice's Avatar
bprice bprice is offline
Member
 
Join Date: Oct 2006
Location: Edmundston, New Brunswick, Canada
Posts: 89
Default

WOW! very nice guys! All excellent work! Thank you very much for the help! Now that I have these little snippets of code... I can add on to the rest easily. I'll try and post my progress in hopes maybe someone else will be able use my idea later!

Thanks again for all your help!

B
Reply With Quote
  #9  
Old 08-02-2008, 08:52
Craig Tucker
Guest
 
Posts: n/a
Default Larger Box...

Hi BPrice,
You might consider creating one box the whole length of the right side and insert text accordingly. This way you can get the attributes such as font size, alignment, color, etc. from another shape used as a sample. Use line feeds to move down. This is how we do menus (because we never know how many hamburgers there will be! Hamburger Title, Description, and Price - different size, alignment, and color respectively...)
HTH, Craig...

s2.Text.Story.InsertAfter (vbCrLf)
Set lcTextRange = s2.Text.Story.InsertAfter(s1.Text.Story, s1.Text.Story.LanguageID, s1.Text.Story.Charset, s1.Text.Story.Font)
lcTextRange.Size = s1.Text.Story.Size
lcTextRange.Alignment = s1.Text.Story.Alignment
lcTextRange.Fill.UniformColor = s1.Fill.UniformColor
If s2.Text.Overflow = True Then
lcImageError = "1026_" & lcMenuNumber
End If
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
leading (line spacing) between lines of artistic text that have different font size michael_maberly General 4 15-07-2007 11:07
Striping a word down to the first letter only knowbodynow CorelDRAW/Corel DESIGNER VBA 9 19-04-2007 15:14
Select specified text, change font size? fiddler2b CorelDRAW/Corel DESIGNER VBA 3 23-04-2006 08:11
How to set margin of text inside shape? wOxxOm General 2 08-03-2006 03:42
How to place a bitmap inside text or other objects? Alex FAQ 1 24-05-2005 11:01


All times are GMT -5. The time now is 08:54.


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