word 中Sentences、Paragraph等含义和用法
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
表达式 含义 返回的对象
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
分类:
office
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理