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 13-09-2005, 05:44
RichT
Guest
 
Posts: n/a
Default how to copy grouped object and edit its text

Hi.

I'm pretty new to Corels VBA (but not this in general) and have a question.

I want a macro to take the currently selected object and copy it X times at Y spacing (easy) but also to increment a number in its text field (hard). In this instance, it is a circle with an embedded text field, which contains a number '1' centred horizontally and vertically. I want the macro to create the next ones in sequence, used for ballooning of items etc. It seems I can't record editing of text in the macro 'Recording of this command is not supported'

Any help appreciated

Rich
Reply With Quote
  #2  
Old 13-09-2005, 06:31
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Here is something for you to start with:

Code:
Sub DuplicateTextInsideShape()
    Dim srDup As ShapeRange
    Dim s As Shape
    Dim nVal As Long
    
    ' Duplicate the selection first
    Set srDup = ActiveSelectionRange.Duplicate(4, 0)
    ' Find if there is a text in the duplicate, and if it contains a number, increment it
    For Each s In srDup
        If s.Type = cdrTextShape Then
            ' If the text is inside another shape
            If s.Text.Frame.IsInsideContainer Then
                ' If the text block is not empty
                If Trim$(s.Text.Story) <> "" Then
                    ' Get the current numeric value of the text
                    nVal = Val(s.Text.Story)
                    ' Increment the value
                    nVal = nVal + 1
                    ' Set it back to the text
                    s.Text.Story = CStr(nVal)
                End If
            End If
        End If
    Next s
End Sub
Reply With Quote
  #3  
Old 13-09-2005, 08:36
RichT
Guest
 
Posts: n/a
Default

Wow! Thanks Alex. That is exactly what I need.

Very much appreciated!

thanks again

Rich
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
Text selection problem ken_ac CorelDRAW/Corel DESIGNER VBA 2 10-02-2004 20:24


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


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