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 16-12-2005, 16:01
JavierDiaz
Guest
 
Posts: n/a
Default Fix Object References in macros

Hi:

I would like some guidance in making macros that manipulate fix objects in a document.

For example, lets say i have an object named "Circle" and i would like to simple move this object around the document or delete it.

I've tried different things, but i never seem to be able to get my macro to work only with one object.

This is a sample of what I got so far (it's not much or complicated at all)

Sub MoveCircle()

Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
OrigSelection.move 3.303638, -0.141181
End Sub

As you can see, this macro only works with the object u select (which i believe is to make macros of general use?).

Thanks in advance for your time.

Javier Diaz
Reply With Quote
  #2  
Old 19-12-2005, 07:21
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

use the method...
Code:
ActivePage.FindShapes("Circle")
then add the code to move your object. You can also use this code in it's recursive state to process objects within a group, like this...
Code:
ActivePage.FindShapes()
if s.Name = "Circle" then
'do something with the shape
Here is a macro that I wrote to set all outlines to scale with the object...
Code:
Option Explicit

Sub ScaleOutlines()
    On Error Resume Next
    Dim s As Shape
    Dim d As Document
    
    For Each s In ActivePage.FindShapes()
        If s.Outline.Width <> 0# Then
            If s.Outline.ScaleWithShape = False Then
                s.Outline.ScaleWithShape = True
            End If
        End If
    Next s
End Sub
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #3  
Old 19-12-2005, 07:32
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Just to add to Sean's post above, here is a complete code which will look for a named object and move it:

Code:
Sub MoveCircle()
    Dim s As Shape
    Set s = ActivePage.FindShape("Circle")
    If Not s Is Nothing Then
        s.Move 2, 0
    End If
End Sub
If you are sure that the object name Circle is guaranteed to exist on the page and it is on the first level of object hierarchy (not inside of a group or something), you can find it using just the Shapes collection:

Code:
Sub MoveCircle2()
     ActivePage.Shapes("Circle").Move 2, 0
End Sub
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
New macros: Oberon Object Tiler & Oberon Color Replacer Alex Site News 1 06-11-2009 19:49
Corel, Options, Customization, Commands, macros, "Separ Rick Randall CorelDRAW/Corel DESIGNER VBA 5 14-05-2009 11:20
Background to object Fine! But Object to Background - How? marian General 2 15-07-2005 03:51
Bounding lines around an object toy4mud CorelDRAW CS 2 04-11-2004 11:56
Would you miss CorelScript object? Alex CorelDRAW/Corel DESIGNER VBA 32 04-02-2004 14:59


All times are GMT -5. The time now is 04:12.


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