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 06-11-2006, 05:47
nikhiscd
Guest
 
Posts: n/a
Default character count

how do I count the number of characters in shape.text

Last edited by nikhiscd; 06-11-2006 at 06:26.
Reply With Quote
  #2  
Old 06-11-2006, 07:53
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

This should be what you are looking for...
Code:
Option Explicit

Sub CountLetters()
    Dim LetterArray(33 To 255) As Long
    Dim n As Long
    Dim s As Shape
    Dim strText As String
    Dim c As Integer
    
    For n = 33 To 255
        LetterArray(n) = 0
    Next n
    
    For Each s In ActivePage.FindShapes(Type:=cdrTextShape)
        strText = s.Text.Frame.Range.Text
        For n = 1 To Len(strText)
            c = Asc(Mid$(strText, n, 1))
            If c > 32 And c < 256 Then
                LetterArray(c) = LetterArray(c) + 1
            End If
        Next n
    Next s
    
    strText = "Letter occurence statistics:" & vbCrLf
    For n = 33 To 255
        If LetterArray(n) > 0 Then
            strText = strText & Chr$(n) & " = " & LetterArray(n) & vbCrLf
        End If
    Next n
    
    With CreateDocument
        .ActiveLayer.CreateParagraphText 0, 0, .ActivePage.SizeWidth, .ActivePage.SizeHeight, strText
    End With
End Sub
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #3  
Old 06-11-2006, 09:15
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,791
Blog Entries: 15
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 Char Count

Or if you want everything you can do something like this:
Code:
Sub Test()

Dim s As Shape
Dim d As Document
Dim t As Text

Set d = CreateDocument
Set s = d.ActiveLayer.CreateParagraphText(2, 2, 8, 8, "This is a test.")

Set t = s.Text
MsgBox t.Story.Characters.Count

End Sub
Best,

Shelby
Reply With Quote
  #4  
Old 22-06-2008, 04:26
sakis_drm
Guest
 
Posts: n/a
Smile Breaking apart text until letters

Maybe the original post need the code below..
Anyway it is a usefull and parametric sub!

Code:
Public Sub BreakApartToLetters(intMainLoops as integer)
Dim cdrShape As Shape
Dim intCounter As Integer
    For intCounter = 1 To intMainLoops
        For Each cdrShape In ActiveDocument.ActivePage.Shapes
            If cdrShape.Type = cdrTextShape Then
                cdrShape.BreakApart
            End If
        Next
    Next
End Sub
The steps for each main loop are the below...
1. Paragraph to lines
2. Lines to words
3. Words to letters

So when you have paragraphs
intMainLoops = 3 ....and you will get letters
intMainLoops = 2 ....and you will get words
intMainLoops = 1 ....and you will get lines

when lines
intMainLoops = 2 ....and you will get letters
intMainLoops = 1 ....and you will get words

when words
intMainLoops = 1 ....and you will get letters

It affects on all objects in the active page.
You could do it on the selection by altering the "ActiveDocument.ActivePage.Shapes" with "Selection".

Last edited by sakis_drm; 22-06-2008 at 04:30. Reason: Adding tabs
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
CDR12: TTF Font exporting - specify character code zlatev CorelDRAW/Corel DESIGNER VBA 0 03-12-2005 05:54
insert a character by vba beny04 CorelDRAW/Corel DESIGNER VBA 8 16-05-2005 02:45
Gradient + Break Apart Hernán New product ideas 6 25-04-2004 14:34
how to insert a character CHR(216)? ama CorelDRAW/Corel DESIGNER VBA 2 17-03-2004 07:55
Whether the VBA can work with Unicode . Dino CorelDRAW/Corel DESIGNER VBA 5 27-08-2003 16:13


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


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