statistics value in VBA word

M

Max

Hi,

I use the following command:
Application.Dialogs(wdDialogDocumentStatistics).Show
under VBA to show statistics for a word document.
What is the command for capturing these information in
variables?

Regards, Max
 
J

Jezebel

With Dialogs(wdDialogDocumentStatistics)
MyVar = .FileName
MyVar2 = .Paragraphs
.. etc
End With

See 'Built-in dialog box argument lists' in Help for the full list of
properties.
 
D

Doug Robbins - Word MVP

Hi Max,

MsgBox ActiveDocument.BuiltInDocumentProperties(wdPropertyWords)
MsgBox ActiveDocument.BuiltInDocumentProperties(wdPropertyLines)
MsgBox ActiveDocument.BuiltInDocumentProperties(wdPropertyCharacters)
MsgBox ActiveDocument.Paragraphs.Count
MsgBox ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
MsgBox ActiveDocument.BuiltInDocumentProperties(wdPropertyBytes)


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
P

Peter Hewett

Hi Max

And I use yet another method as it's very flexible:

Public Sub DocumentStatistics()
Dim rngReplace As Word.Range
Dim rngFound As Word.Range
Dim lngCharacters As Long
Dim lngCharactersWithSpaces As Long
Dim lngFarEastCharacters As Long
Dim lngLines As Long
Dim lngPages As Long
Dim lngParagraphs As Long
Dim lngWords As Long

' Get the totals for the document
With ActiveDocument
lngCharacters = .ComputeStatistics(wdStatisticCharacters)
lngCharactersWithSpaces = _
.ComputeStatistics(wdStatisticCharactersWithSpaces)
lngFarEastCharacters = _
.ComputeStatistics(wdStatisticFarEastCharacters)
lngLines = .ComputeStatistics(wdStatisticLines)
lngPages = .ComputeStatistics(wdStatisticPages)
lngParagraphs = .ComputeStatistics(wdStatisticParagraphs)
lngWords = .ComputeStatistics(wdStatisticWords)
End With
End Sub

HTH + Cheers - Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top