zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    使用std::accumulate计算和、积和平均值
    Boost文件读写,断言、日期
    mem_fun的用法,以及使用wcout
    singleton的内存泄漏及线程安全性问题
    delphi关键字
    Windows Api的一些方法 封装 以及 常用参数
    linux字符设备驱动 自动创建设备节点的的方法
    Linux混杂设备注册方法
    linux2.6字符设备的标准注册方法
    另一种linux下的powerpc中断注册的方法
  • 原文地址:https://www.cnblogs.com/gisoracle/p/1565112.html
Copyright © 2011-2022 走看看