Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2005

Tip: Looking for answers? Try searching our database.

How to count the characters in header/footer?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paresh - 28 Aug 2005 11:08 GMT
Can anybody give me the macro code to find the character count of the
contents in header/footer?

Thanks!

Paresh
Doug Robbins - 28 Aug 2005 11:27 GMT
MsgBox
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Characters.Count
MsgBox
ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range.Characters.Count

It includes spaces and carriage returns.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Can anybody give me the macro code to find the character count of the
> contents in header/footer?
>
> Thanks!
>
> Paresh
Paresh - 29 Aug 2005 07:58 GMT
Thanks for the tip.

Regards,
Paresh

> MsgBox
> ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Characters.Count
[quoted text clipped - 9 lines]
> >
> > Paresh
Greg - 29 Aug 2005 13:28 GMT
You could omit the count of spaces, line breaks and paragraph returns
with something like:

Sub CountCharacters()
Dim oChr As Range
Dim i As Long
For Each oChr In
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Characters
Select Case Asc(oChr)
 Case Is = 11, 13, 32 'The Asc Code for a paragraph, line break, and
space
   i = i
 Case Else
   i = i + 1
End Select
Next
MsgBox "The header contains " & i & " characters."
End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.