![]() |
#1
|
|||
|
|||
![]()
how do I count the number of characters in shape.text
Last edited by nikhiscd; 06-11-2006 at 06:26. |
#2
|
||||
|
||||
![]()
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. |
#3
|
||||
|
||||
![]()
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 Shelby |
#4
|
|||
|
|||
![]()
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 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 |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
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 |