Rakesh
09-05-2014, 04:19 PM
Hi Guys,
I have tried to create a macro to count the Total tab of every paragraph and to make that as a string. But at last I have got the Total Tab count of Document and Stuck.
Please Let me know, How to loop each and every paragraph and to get the Total tab count as string.
The below coding for your reference.
Sub CountChars2()
Dim iCount(0 To 255) As Long
Dim i As Long
Dim j As Integer
Dim lCharCount As Long
Dim sDoc As String
Dim sTemp As String
' Initialize the array
For i = 0 To 255
iCount(i) = 0
Next i
' Assign document to a huge string
lCharCount = ActiveDocument.Characters.Count
sDoc = ActiveDocument.range(0, lCharCount)
' Fill the array
For i = 1 To Len(sDoc)
j = Asc(Mid(sDoc, i, 1))
iCount(j) = iCount(j) + 1
Next
' Only output code 9
For i = 9 To 0
sTemp = Chr(i)
If i < 32 Then sTemp = Trim(str(i))
sTemp = sTemp & Chr(9) & Trim(str(iCount(i)))
Next i
MsgBox iCount(i)
End Sub
Thanks in advance,
Rakesh
I have tried to create a macro to count the Total tab of every paragraph and to make that as a string. But at last I have got the Total Tab count of Document and Stuck.
Please Let me know, How to loop each and every paragraph and to get the Total tab count as string.
The below coding for your reference.
Sub CountChars2()
Dim iCount(0 To 255) As Long
Dim i As Long
Dim j As Integer
Dim lCharCount As Long
Dim sDoc As String
Dim sTemp As String
' Initialize the array
For i = 0 To 255
iCount(i) = 0
Next i
' Assign document to a huge string
lCharCount = ActiveDocument.Characters.Count
sDoc = ActiveDocument.range(0, lCharCount)
' Fill the array
For i = 1 To Len(sDoc)
j = Asc(Mid(sDoc, i, 1))
iCount(j) = iCount(j) + 1
Next
' Only output code 9
For i = 9 To 0
sTemp = Chr(i)
If i < 32 Then sTemp = Trim(str(i))
sTemp = sTemp & Chr(9) & Trim(str(iCount(i)))
Next i
MsgBox iCount(i)
End Sub
Thanks in advance,
Rakesh