OberonPlace.com Forums  

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

Thread Tools Search this Thread Display Modes
Old 14-04-2007, 01:54
knowbodynow knowbodynow is offline
Senior Member
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default Checking If Artistic Text is on a rectangle shape


I'd like to be able to check if any artistic text on a page is sitting on top of a rectangle shape. If so I want to centre it to the rectangle. I know how to centre the text but can't find a way to automatically check if it is on top of a rectangle shape. I looked at IsOnShape but couldn't see a way to use it. Is there any other simple method I've overlooked? It needs to be simple as I can't deal with a complicated one!


Chris (Hunt)
Reply With Quote
Old 15-04-2007, 10:29
Alex's Avatar
Alex Alex is offline
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4

Well, the easiest way is to check whether the center of the text is on top of a rectangle. Obviously, this isn't 100% foolproof, but is good enough for most application (I suppose you need the most of the text to be on top of rectangle, not just touching the rectangle).

Sub CenterTextOverRectangles()
    Dim sText As Shape
    Dim sRect As Shape
    Dim x As Double, y As Double
    Dim sRectFound As Shape
    ActiveDocument.ReferencePoint = cdrCenter
    For Each sText In ActivePage.Shapes.FindShapes(Type:=cdrTextShape)
        Set sRectFound = Nothing
        sText.GetPosition x, y
        For Each sRect In ActivePage.Shapes.FindShapes(Type:=cdrRectangleShape)
            If sRect.IsOnShape(x, y) <> cdrOutsideShape Then
                Set sRectFound = sRect
                Exit For
            End If
        Next sRect
        If Not sRectFound Is Nothing Then
            sText.AlignToShape cdrAlignHCenter + cdrAlignVCenter, sRect
        End If
    Next sText
End Sub
Reply With Quote
Old 16-04-2007, 18:47
knowbodynow knowbodynow is offline
Senior Member
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434

Thanks Alex, that was exactly what I needed. I don't think I could ever have found such a clear way.

Best wishes,

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
Striping a word down to the first letter only knowbodynow CorelDRAW/Corel DESIGNER VBA 9 19-04-2007 16:14
Any idea what's wrong with this shape? jemmyell CorelDRAW/Corel DESIGNER VBA 4 08-05-2006 19:15
Text selection and sizing ddonnahoe CorelDRAW/Corel DESIGNER VBA 5 17-05-2005 14:19
Getting the center X on a text shape Rick Randall CorelDRAW/Corel DESIGNER VBA 4 03-08-2004 19:27
Placing a custom envelope on Text larrypanattoni CorelDRAW/Corel DESIGNER VBA 3 23-04-2003 10:18

All times are GMT -5. The time now is 03:36.

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