OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Corel User Forums > CorelDRAW > Macros/Add-ons

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 17-09-2011, 21:11
HeauxmBru
Guest
 
Posts: n/a
Default Selection with GetUserArea

I'm having a little trouble actually selecting an existing shape with GetUserArea. The function returns the selected coordinates and it is easy enough to create a new shape with that info, but how is it used to select an existing shape? I've been unable to find anything on this.

Code:
    Set d = ActiveDocument
'    Set s = d.Selection
    
TryAgain:

    b = d.GetUserArea(x1, y1, x2, y2, Shift, 10, False, cdrCursorWinCross)
        If Not b Then
            
'            Set s = d.ActiveLayer.CreateRectangle(x1, y1, x2, y2)

Should do something here

            If s.Shapes.Count = 0 Then
                If MsgBox("You did not select an object." _
                        & Chr(13) & "Would you like to try again?", _
                        vbYesNo, "Try Again") = 7 Then
                    d.ClearSelection
                    Exit Sub
                Else
                    GoTo TryAgain
                End If
            End If
I could use a little direction.
Reply With Quote
  #2  
Old 18-09-2011, 19:43
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

HI.
What about:

Page.SelectShapesFromRectangle
Function SelectShapesFromRectangle(x1 As Double, y1 As Double, x2 As Double, y2 As Double, Touch As Boolean) As Shape

Description
Member of Page

The SelectShapesFromRectangle method selects all shapes within a given rectangle as if selected with a marquee.

This method creates a new selection and returns the selection-shape object.


Parameter Description
x1 Specifies the x-coordinate of the upper-left corner of the rectangle, measured in document units
y1 Specifies the y-coordinate of the upper-left corner of the rectangle, measured in document units
x2 Specifies the x-coordinate of the lower-right corner of the rectangle, measured in document units
y2 Specifies the y-coordinate of the lower-right corner of the rectangle, measured in document units
Touch Specifies whether to select shapes not completely enclosed within the rectangle
True selects shapes not completely enclosed within the rectangle.


VBA example
The following VBA example allows the user to pick a color, which is used to fill all shapes in a defined area. This procedure repeats until Esc is pressed.

Code:
Sub Test() 
 Dim d As Document 
 Dim sel As Shape, s As Shape 
 Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double, Shift As Long 
 Dim c As New Color 
 Set d = ActiveDocument 
 c.UserAssign 
 While d.GetUserArea(x1, y1, x2, y2, Shift, 100, False, cdrCursorWinCross) = 0 
  Set sel = d.ActivePage.SelectShapesFromRectangle(x1, y1, x2, y2, False) 
  For Each s In sel.Shapes 
   s.Fill.ApplyUniformFill c 
  Next s 
 Wend 
End Sub
~John
Reply With Quote
  #3  
Old 19-09-2011, 20:59
HeauxmBru
Guest
 
Posts: n/a
Default

I knew it was there somewhere. I've even seen it before. I just couldn't find it. I should've kept looking. But I certainly appreciate the push in the right direction. Thanks John.
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
Bug with existing selection m31uk3 Code Critique 1 02-01-2008 19:18
Object Selection norbert_ds CorelDRAW/Corel DESIGNER VBA 4 17-04-2007 09:52
selection handles gone?? HELP! roachy General 4 06-04-2006 21:08
Automatic Selection Jim Holt General 1 16-02-2006 11:13
StaticID Selection dimmech CorelDRAW/Corel DESIGNER VBA 2 11-03-2004 23:16


All times are GMT -5. The time now is 14:05.


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