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-12-2003, 03:30
ssb
Guest
 
Posts: n/a
Default Number counter on array of objects

I need some kind of VBA code allowing creation of a counter that can create an array of selected object where every number increase by a specific step.
For exaple i have some kind of badge with a serial number on its bottom, i need a script to create hundrends of copies of the same badge with serialization.
Any help ?

Thank you
Reply With Quote
  #2  
Old 04-12-2003, 12:19
cutter
Guest
 
Posts: n/a
Default

I've got the same problem, but i haven't heard anything yet. I 'think' Coreldraw doesn't recognize numbers as numbers but as just another object. Not sure if that's true or not but would be interested in knowing.

cutter
Reply With Quote
  #3  
Old 04-12-2003, 13:47
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default Re: Number counter on array of objects

Have you tried using CorelDRAW's Print Merge feature? It can do just that but when printing. If you need to create a document with all your badges in it, you will either have to create a macro or use something like Name Drop Express.

If you are going with your own macro, generally what you need to do is to identify your text object which will contain the number (you can give it a special name or place a special text string in it).

Then just duplicate the selected objects, go through every object in selection and find your text shape. Replace its text string with the current number. Finally increment the counter, and proceed to the duplicated objects and repeat the operations.
Reply With Quote
  #4  
Old 06-12-2003, 02:23
ssb
Guest
 
Posts: n/a
Default

Thank you Alex and Cutter.
I'm gona write my own script for such a function because is something i really need.
Reply With Quote
  #5  
Old 08-12-2003, 11:47
DaSaint
Guest
 
Posts: n/a
Default Re: Number counter on array of objects

Hello.

Alex.. my question to you..

if its possible to create that Calendar wizard.. how do we make thing like

A rectangle, text in it like 00001 and the automatic duplication of this rectangle with text enumeration till like let's say 00800.

If i get things right.. it ain't immpossible..

Thank you in advance because the numbers I must create end far not with 800...
Reply With Quote
  #6  
Old 08-12-2003, 15:37
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default Re: Number counter on array of objects

Quote:
Originally Posted by DaSaint
if its possible to create that Calendar wizard.. how do we make thing like

A rectangle, text in it like 00001 and the automatic duplication of this rectangle with text enumeration till like let's say 00800.

If i get things right.. it ain't immpossible..
Of course it's possible. Who said it wasn't?

Here is the sample code. Just create a few objects with an artistic text object. Give the artistic text object a name "Number" (in Object Manager or in Object Data Manager docker). Then select all the objects and run the macro. It will create 100 copies and number all of them consecutively. It will create no more than 32 copies per page ( 4 x 8 ).

Code:
Sub NumberAndDuplicate()
    Const NumX As Long = 4              ' Number of copies horizontally
    Const NumY As Long = 8              ' Number of copies vertically
    Const DupCount As Long = 100        ' Total number of copies
    
    Dim sr As ShapeRange
    Dim nx As Long, ny As Long
    Dim n As Long
    
    nx = 0
    ny = 0
    Set sr = ActiveSelectionRange
    ActiveDocument.ReferencePoint = cdrTopLeft
    For n = 1 To DupCount
        PlaceObjects sr, n, nx, ny
        If n <> DupCount Then
            Set sr = sr.Duplicate(20, 20) ' To make sure that the copy is on the desktop
        End If
        nx = nx + 1
        If nx >= NumX Then
            nx = 0
            ny = ny + 1
            If ny >= NumY Then
                ny = 0
                ActiveDocument.AddPages 1
            End If
        End If
    Next n
End Sub

Private Sub PlaceObjects(ByVal sr As ShapeRange, ByVal n As Long, ByVal nx As Long, ByVal ny As Long)
    Const PageMargin As Double = 0.5    ' Page Margin = 0.5"
    Const Spacing As Double = 0.2       ' Object Spacing, 0.2"

    Dim s As Shape
    Dim x As Double, y As Double
    sr.CreateSelection
    x = PageMargin + nx * (sr.SizeWidth + Spacing)
    y = ActivePage.SizeHeight - PageMargin - ny * (sr.SizeHeight + Spacing)
    ActiveSelection.SetPosition x, y
    Set s = ActiveSelection.Shapes.FindShape("Number", cdrTextShape)
    If Not s Is Nothing Then
        s.Text.Story = Format$(n, "000000") ' Format the serial number
    End If
End Sub
Reply With Quote
  #7  
Old 09-12-2003, 03:10
DaSaint
Guest
 
Posts: n/a
Default

well i made it .. pasted it as is.
on F5 i get syntax error..

(6) Error: Syntax error at symbol "SHAPERANGE".
(12) Error: Syntax error at symbol "SR".
(13) Fatal error: Dialog or dialog control not specified.
3 error(s), 0 warning(s).

I'm using Corel 9
I'm a newbie to all this so
forgive me my failures...
Reply With Quote
  #8  
Old 09-12-2003, 04:04
DaSaint
Guest
 
Posts: n/a
Default

I'm going trough all the manual for scripting.. and it didn't even find the type "ShapeRange"..

Is there a substitute i can use?
Reply With Quote
  #9  
Old 09-12-2003, 07:59
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Quote:
Originally Posted by DaSaint
I'm going trough all the manual for scripting.. and it didn't even find the type "ShapeRange"..

Is there a substitute i can use?
The above code is in VBA for CorelDRAW 11. It would be so much more difficult to rewrite this in CorelScript under CorelDRAW 9.
Reply With Quote
  #10  
Old 09-12-2003, 08:01
DaSaint
Guest
 
Posts: n/a
Default

aha
I'll see what's up =]

DS
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
fit objects to path edges geopig Other Oberon Commercial Products 1 03-08-2006 00:28
Find objects by properties Webster CorelDRAW/Corel DESIGNER VBA 8 01-12-2004 19:51
Letter and Number Counter ddonnahoe CorelDRAW/Corel DESIGNER VBA 5 05-11-2004 14:27
Need help accessing objects in a group ama CorelDRAW/Corel DESIGNER VBA 5 20-02-2004 12:28
I need to update objects visibility faster NEHovis Corel Photo-Paint VBA 0 18-07-2003 08:54


All times are GMT -5. The time now is 22:06.


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