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 04-09-2009, 00:10
svk
Guest
 
Posts: n/a
Default Creating Square arround a selected object

Hi This is probably my first attempt at vb

I want to create a square of 12 mm X 12 mm arround a selected object which is 1 mm in size, I recorded a macro and tried to play arround it but I am unable to get the rectangle where I want.

Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
Dim s1 As Shape
Set s1 = ActiveLayer.CreateRectangle(OrigSelection.RotationCenterX, OrigSelection.RotationCenterY, OrigSelection.SizeWidth * 12, OrigSelection.SizeHeight * 12)
s1.Fill.ApplyNoFill
s1.Outline.SetProperties 0.02, OutlineStyles(0), CreateCMYKColor(0, 0, 0, 100), ArrowHeads(0), ArrowHeads(0), False, False, cdrOutlineButtLineCaps, cdrOutlineMiterLineJoin, 0#, 100, , , 5#

What do I write in the red fields so that I get the square at the centre of selected obj.

Thaking you.
Reply With Quote
  #2  
Old 04-09-2009, 07:29
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

Two things you can do here.
1. You can make your page size 12mm x 12mm and then double click the rectangle tool on the toolbar (this outlines the page with a rectangle), or
2. Select your object and hold the shift key and double click on the rectangle tool. Then resize your rectangle to 12mm x 12mm.

No VBA needed.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #3  
Old 04-09-2009, 13:32
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default CreateRectangle

I find it easier to do with this CreateRectangle2, hope this helps.
Code:
Sub CreateMyRectanlge()
    Const dblSize As Double = 12
    Dim srSelection As ShapeRange, sRect As Shape
    Dim x As Double, y As Double
    
    ActiveDocument.Unit = cdrMillimeter
    ActiveDocument.ReferencePoint = cdrCenter
    
    Set srSelection = ActiveSelectionRange
    srSelection.GetPosition x, y
    
    Set sRect = ActiveLayer.CreateRectangle2(x - (dblSize / 2), y - (dblSize / 2), dblSize, dblSize)
End Sub
-Shelby
Reply With Quote
  #4  
Old 17-10-2011, 07:21
buga buga is offline
Senior Member
 
Join Date: Jan 2011
Posts: 114
Default

Shelby a question.

What exactly does the code?

not working
Reply With Quote
  #5  
Old 17-10-2011, 13:05
buga buga is offline
Senior Member
 
Join Date: Jan 2011
Posts: 114
Default

It works.

Something was happening, because it did not work.

I restarted corel, and works

thanks
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
enable check box in form only if object is selected L_G_D CorelDRAW/Corel DESIGNER VBA 9 08-04-2009 07:17
Macro to hide all but the selected object cooloox Macros/Add-ons 2 28-09-2008 21:19
CD X3 creating a boundary from an object psypha General 2 02-08-2007 11:44
Selected object to other page Duplicate method ? ljesus7 CorelDRAW/Corel DESIGNER VBA 5 12-02-2007 16:37
Retrieve Color Values from Selected Object Jon Lorber CorelDRAW/Corel DESIGNER VBA 2 19-08-2004 07:24


All times are GMT -5. The time now is 20:57.


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