View Single Post
Old 13-09-2005, 06:31
Alex's Avatar
Alex Alex is offline
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4

Here is something for you to start with:

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