A
andreas
Dear Experts:
I would like to paste the contents of the MsgBox into a new Document
with the following heading:
The document statistics for the current document <document name on
which the macro was run> is as follows:
(This heading should be wdStyleNormal and bold formatted).
Each statisical data should be on its own paragraph (wdStyleNormal),
not bold.
Help is much appreciated. Thank you very much in advance. Regards,
Andreas
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
Dim newDoc As Document
Dim strMsg As String
If MsgBox("Would you like to list all Document Statistics at the
end of the document?" & vbCrLf & _
"Would you like to continue?", vbQuestion + vbYesNo, "List all
Document statistics") = vbNo Then
Exit Sub
End If
' 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)
MsgBox lngCharacters & " Characters " & lngLines & " Lines " &
lngWords & " Words" & lngParagraphs & " Paragraphs"
End With
End Sub
I would like to paste the contents of the MsgBox into a new Document
with the following heading:
The document statistics for the current document <document name on
which the macro was run> is as follows:
(This heading should be wdStyleNormal and bold formatted).
Each statisical data should be on its own paragraph (wdStyleNormal),
not bold.
Help is much appreciated. Thank you very much in advance. Regards,
Andreas
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
Dim newDoc As Document
Dim strMsg As String
If MsgBox("Would you like to list all Document Statistics at the
end of the document?" & vbCrLf & _
"Would you like to continue?", vbQuestion + vbYesNo, "List all
Document statistics") = vbNo Then
Exit Sub
End If
' 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)
MsgBox lngCharacters & " Characters " & lngLines & " Lines " &
lngWords & " Words" & lngParagraphs & " Paragraphs"
End With
End Sub