word 中有Words,Characters,Sentences、Paragraph,Sections 具体含义如下
表达式 含义 返回的对象
Words(index) 单词 Range
Characters(index) 字符 Range
Sentences(index) 句子 Range
Paragraphs(index) 段落 Paragraph
Sections(index) 节 Section
一般情况,一个文档是有几个节(Sections)组成,一节有几段(Paragraphs),
每段有几句(Sentences)组成,每句又有几个单词Words组成,每个单词有几个字符组成
如下文档,有两节,三段,大概如下,具体见附件
Excelhome是一个不错的网站,你不只是Execl的家,也是word,ppt的家,我们都喜欢你。希望你越办越好。
gisOracle是一个不错的人,他做不少关于word,ppt的软件。如word转图片pdf,word编号工具,word转图片word;ppt转换图片pdf,ppt转换图片ppt,我希望他的软件。
--有分节符
Microsoft 的Office做的很好,相信他会做的更好。
vba如下
Private Sub CommandButton1_Click()
MsgBox "当前文档有" & ActiveDocument.Sections.Count & "节"
Dim i, j As Integer
i = 1
Dim oSection As Section
For Each oSection In ActiveDocument.Sections
MsgBox "当前文档第" & i & "节,的内容:" & oSection.Range.Text
i = i + 1
Next
MsgBox "当前文档有" & ActiveDocument.Paragraphs.Count & "段"
i = 1
Dim oParagraph As Paragraph
Dim oSentence As Range
For Each oParagraph In ActiveDocument.Paragraphs
MsgBox "当前文档第" & i & "段,的内容:" & oParagraph.Range.Text
j = 1
For Each oSentence In oParagraph.Range.Sentences
MsgBox "当前文档第" & i & "段,的内容,第" & j & "句的内容:" & oSentence.Text
j = j + 1
Next
i = i + 1
Next
i = 1
Dim oword As Range
For Each oword In ActiveDocument.Words
MsgBox "当前文档第" & i & "单词,的内容:" & oword.Text
If i = 1 Then
For j = 1 To oword.Characters.Count
MsgBox "当前文档第" & i & "单词的第:" & j & "字符为:" & oword.Characters.Item(j).Text
Next
End If
i = i + 1
Next
End Sub