以下是引用duke008在2006-9-19 17:01:02的发言: 附件已上传.希望统计结果和用word本身的字数统计功能统计出的"字数"一样. 我做了一个,请楼主详测。 '* +++++++++++++++++++++++++++++ '* Created By SHOUROU@ExcelHome 2006-9-20 6:25:07 '仅测试于System: Windows NT Word: 11.0 Language: 2052 '№ 0072^The Code CopyIn [ThisDocument-ThisDocument]^' '* ----------------------------- Option Explicit Public WithEvents wdApp As Word.Application Dim myString As String Private Sub Document_Open() Set wdApp = Word.Application End Sub '----------------------
Private Sub wdApp_MailMergeAfterMerge(ByVal Doc As Document, ByVal DocResult As Document) Dim i As Section, L As Long, myVar As Variant, N As Long On Error Resume Next myVar = VBA.Split(myString, "\") For Each i In DocResult.Sections N = N + 1 i.Range.Paragraphs(3).Range.Text = "字数:" & myVar(N) Next End Sub '----------------------
Private Sub wdApp_MailMergeAfterRecordMerge(ByVal Doc As Document) Dim myBar As CommandBar, CharsCount As String Application.ScreenUpdating = False Doc.Fields(Doc.Fields.Count).Select Set myBar = Word.CommandBars("Word Count") Application.Run "ToolsWordCountRecount" CharsCount = myBar.Controls(1).List(1) myString = myString & "\" & CharsCount Application.ScreenUpdating = True End Sub '----------------------
6n8HMaX9.rar
(10.74 KB, 下载次数: 10)
|