怎么快速取得word文档的结构?

hugebrush 2014-05-06 09:50:07
我目前用的办法是遍历文档的段落,根据各段落outlinelevel属性建立文档结构,但这种方法效率非常低,我处理一个1000多页的文档要几十分钟,而word打开同一个文档,3、4秒钟就能在导航窗格中显示出文档结构,很显然word有其他方式取得文档结构。怎么用VBA快速取得word文档结构?

用“GetCrossReferenceItems wdRefTypeHeading”有个问题:我处理的文档有些标题只设置大纲级别,没有应用标题样式,“GetCrossReferenceItems wdRefTypeHeading”返回的结果中缺少这些标题,但word导航窗格显示有这些标题。
...全文
776 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hqzm0401 2014-08-01
  • 打赏
  • 举报
回复
<p class=p0 style=text-indent:21.0000pt;>
<span style=font-size:10.5000pt;font-family:'宋体';>整合营销原是市场营销的一种有效营销方式,随着网络营销的发展,网络整合营销也逐渐兴起并被广泛应用到各企业中,整合营销要求将目前最有效的多种网络营销方式优势结合,能够让企业的网络营销效果更显著。那么如何进行<a target=_blank href=http://www.seo3800.com>网络整合营销</a>呢?笔者接下来就说说自己的一些经验之谈:</span><span style=font-size:10.5000pt;font-family:'宋体';></span>
</p>
<p class=p0 style=text-indent:21.0000pt;>
<span style=font-size:10.5000pt;font-family:'宋体';> </span>
</p>
<p class=p0 style=margin-left:39.0000pt;text-indent:-18.0000pt;>
<span style=font-size:10.5000pt;font-family:'Times;><span>1、<span> </span></span></span><span style=font-size:10.5000pt;font-family:'宋体';>制定详细的计划</span><span style=font-size:10.5000pt;font-family:'宋体';></span>
</p>
<p class=p0 style=margin-left:21.0000pt;>
<span style=font-size:10.5000pt;font-family:'宋体';> </span>
</p>
<p class=p0 style=text-indent:21.0000pt;>
<span style=font-size:10.5000pt;font-family:'宋体';>整合营销要做多种营销方式,为了保证企业的网络整合营销能够有序进行,必须要制定详细的计划。这个计划并不是随意制定的,首先要了解网络市场行情,以及同行的一些营销情况,然后结合公司的实际情况,制定详细的计划,这个计划应该包括整个网络整合营销大概要持续多长时间,分几个阶段进行,每个阶段要运用哪几种营销方式,这样才能保证网络整合营销有序进行。</span><span style=font-size:10.5000pt;font-family:'宋体';></span>
</p>
<p class=p0 style=text-indent:21.0000pt;>
<span style=font-size:10.5000pt;font-family:'宋体';> </span>
</p>
<p class=p0 style=margin-left:39.0000pt;text-indent:-18.0000pt;>
<span style=font-size:10.5000pt;font-family:'Times;><span>2、<span> </span></span></span><span style=font-size:10.5000pt;font-family:'宋体';>多种营销方式的综合运用</span><span style=font-size:10.5000pt;font-family:'宋体';></span>
</p>
<p class=p0 style=margin-left:21.0000pt;>
<span style=font-size:10.5000pt;font-family:'宋体';> </span>
</p>
<p class=p0 style=text-indent:21.0000pt;>
<span style=font-size:10.5000pt;font-family:'宋体';>网络整合营销要求企业在网络营销的过程中,将多种有效营销方式优势结合,来实现网络营销的显著效果。所以在企业进行网络整合营销的过程中,目前市面上比较有效的网络营销方式,像论坛营销、博客营销、分类信息营销和邮件营销都要运用起来,此外问答营销、事件营销等比较有效的营销方式也可以综合运用。这是个复杂的实现过程,必要的时候可以选择网络营销软件来辅助,像具备多种网络营销方式的<span></span><span>组合营销软件就很不错。</span></span><span style=font-size:10.5000pt;font-family:'宋体';></span>
</p>
<p class=p0 style=text-indent:21.0000pt;>
<span style=font-size:10.5000pt;font-family:'宋体';> </span>
</p>
<p class=p0 style=margin-left:39.0000pt;text-indent:-18.0000pt;>
<span style=font-size:10.5000pt;font-family:'Times;><span>3、<span> </span></span></span><span style=font-size:10.5000pt;font-family:'宋体';>对计划严谨的执行</span><span style=font-size:10.5000pt;font-family:'宋体';></span>
</p>
<p class=p0 style=margin-left:21.0000pt;>
<span style=font-size:10.5000pt;font-family:'宋体';> </span>
</p>
<p class=p0 style=text-indent:21.0000pt;>
<span style=font-size:10.5000pt;font-family:'宋体';>再完美的计划,如果没有严谨地执行,那么也只是空谈,尤其是实现网络整合营销这样一个复杂而且长期的过程。更要对每一个环节都把关,严格地执行。只有高度的执行力才能让企业的网络整合营销达到更加显著的效果。</span><span style=font-size:10.5000pt;font-family:'宋体';></span>
</p>
<p class=p0 style=text-indent:21.0000pt;>
<span style=font-size:10.5000pt;font-family:'宋体';> </span>
</p>
<p class=p0 style=margin-left:39.0000pt;text-indent:-18.0000pt;>
<span style=font-size:10.5000pt;font-family:'Times;><span>4、<span> </span></span></span><span style=font-size:10.5000pt;font-family:'宋体';>对效果的实时跟踪</span><span style=font-size:10.5000pt;font-family:'宋体';></span>
</p>
<p class=p0 style=margin-left:21.0000pt;>
<span style=font-size:10.5000pt;font-family:'宋体';> </span>
</p>
<p class=p0 style=text-indent:21.0000pt;>
<span style=font-size:10.5000pt;font-family:'宋体';>企业在进行网络整合营销的过程中,效果到底怎么样?达到好的效果的原因是什么?如果效果不理想,那么是哪个环节出现了纰漏呢,这些都是企业在做网络整合营销的过程中需要持续跟踪了解的,这样才能及时发现问题,总结经验,达到显著效果。</span><span style=font-size:10.5000pt;font-family:'宋体';></span>
</p>
dsd999 2014-05-07
  • 打赏
  • 举报
回复
Public Sub CreateOutline()
    Dim docOutline As Word.Document
    Dim docSource As Word.Document
    Dim rng As Word.Range

    Dim astrHeadings As Variant
    Dim strText As String
    Dim intLevel As Integer
    Dim intItem As Integer

    Set docSource = ActiveDocument
    Set docOutline = Documents.Add

    ' Content returns only the
    ' main body of the document, not
    ' the headers and footer.
    Set rng = docOutline.Content
    astrHeadings = _
     docSource.GetCrossReferenceItems(wdRefTypeHeading)

    For intItem = LBound(astrHeadings) To UBound(astrHeadings)
        ' Get the text and the level.
        strText = Trim$(astrHeadings(intItem))
        intLevel = GetLevel(CStr(astrHeadings(intItem)))

        ' Add the text to the document.
        rng.InsertAfter strText & vbNewLine

        ' Set the style of the selected range and
        ' then collapse the range for the next entry.
        rng.Style = "Heading " & intLevel
        rng.Collapse wdCollapseEnd
    Next intItem
End Sub

Private Function GetLevel(strItem As String) As Integer
    ' Return the heading level of a header from the
    ' array returned by Word.

    ' The number of leading spaces indicates the
    ' outline level (2 spaces per level: H1 has
    ' 0 spaces, H2 has 2 spaces, H3 has 4 spaces.

    Dim strTemp As String
    Dim strOriginal As String
    Dim intDiff As Integer

    ' Get rid of all trailing spaces.
    strOriginal = RTrim$(strItem)

    ' Trim leading spaces, and then compare with
    ' the original.
    strTemp = LTrim$(strOriginal)

    ' Subtract to find the number of
    ' leading spaces in the original string.
    intDiff = Len(strOriginal) - Len(strTemp)
    GetLevel = (intDiff / 2) + 1
End Function

hugebrush 2014-05-07
  • 打赏
  • 举报
回复
谢谢回复。用“GetCrossReferenceItems wdRefTypeHeading”有个问题:我处理的文档有些标题只设置大纲级别,没有应用标题样式,“GetCrossReferenceItems wdRefTypeHeading”返回的结果中缺少这些标题,但word导航窗格显示有这些标题。
引用 1 楼 dsd999 的回复:
Public Sub CreateOutline()
    Dim docOutline As Word.Document
    Dim docSource As Word.Document
    Dim rng As Word.Range

    Dim astrHeadings As Variant
    Dim strText As String
    Dim intLevel As Integer
    Dim intItem As Integer

    Set docSource = ActiveDocument
    Set docOutline = Documents.Add

    ' Content returns only the
    ' main body of the document, not
    ' the headers and footer.
    Set rng = docOutline.Content
    astrHeadings = _
     docSource.GetCrossReferenceItems(wdRefTypeHeading)

    For intItem = LBound(astrHeadings) To UBound(astrHeadings)
        ' Get the text and the level.
        strText = Trim$(astrHeadings(intItem))
        intLevel = GetLevel(CStr(astrHeadings(intItem)))

        ' Add the text to the document.
        rng.InsertAfter strText & vbNewLine

        ' Set the style of the selected range and
        ' then collapse the range for the next entry.
        rng.Style = "Heading " & intLevel
        rng.Collapse wdCollapseEnd
    Next intItem
End Sub

Private Function GetLevel(strItem As String) As Integer
    ' Return the heading level of a header from the
    ' array returned by Word.

    ' The number of leading spaces indicates the
    ' outline level (2 spaces per level: H1 has
    ' 0 spaces, H2 has 2 spaces, H3 has 4 spaces.

    Dim strTemp As String
    Dim strOriginal As String
    Dim intDiff As Integer

    ' Get rid of all trailing spaces.
    strOriginal = RTrim$(strItem)

    ' Trim leading spaces, and then compare with
    ' the original.
    strTemp = LTrim$(strOriginal)

    ' Subtract to find the number of
    ' leading spaces in the original string.
    intDiff = Len(strOriginal) - Len(strTemp)
    GetLevel = (intDiff / 2) + 1
End Function

现在论文抄袭、学术打假成为学术界、媒体关注的话题。有的学者心存侥幸,有的学者对学术严谨性未加重视等,以至于被相关人士揭发举报,最终身败名裂。而许多毕业生因为种种原因,并未对论文抄袭现象加以重视,最后不能顺利毕业,荒废了几年时间,得不偿失。现在提供论文检测的机构主要来源于三大中文期刊数据库,即中国知网论文检测系统,万方论文相似性检测系统,维普通达检测系统。 现在应用较多的是中国知网和万方的检测系统,但是两者都不是免费的,其中,中国知网的费用相对高,在淘宝上一篇硕士论文的检测费用达到两百元。介于此考虑,我在网上收集了一下,提供免费检测论文的几个网站。虽然与权威检测机构的检测结果不一定完全一致,但肯定对论文的修改是有一定帮助的。免费论文检测 1 PaperPass论文通行证网 www.paperpass.org/index.aspx?f=A4BBA37525E99A492050231C7323CF76 系统推出免费试用功能,通过您的手机号码即可申请。申请成功后,您将免费获得3000字的检测量(每个手机限申请一次)。 注:由于服务器服务能力有限,网站每天(从零点计算)提供1000个用户申请免费试用,申请完为止,请您在每天的较早些时候申请,敬请谅解。 PaperPass.Org网站诞生于2007年,是全球首个中文文献相似度比对系统,运营三年来,已经发展成为最权威、最可信赖的中文原创性检查和预防剽窃的在线网站。目前在用检测版本是汲取了大量的用户意见后开发的,更新了比对算法,比对的效率和准确率大大提高,另外还增加了上传文件、下载报告、引用率统计等实用功能。我们将继续贴近用户需求,升级比对算法,为用户提供更为专业的论文原创性检测服务。 2 维普通达检测系统 http://gocheck.cn/s/8059 第一次成功充值之后即赠送第一次充值额度10%的积分,截止到4月1日,先注册先得哦。 维普-通达论文引用检测系统(简称VTTMS)是由重庆维普资讯有限公司与通达恒远(北京)信息技术有限公司共同研制而成,该系统结合了维普资讯的数据资源优势与通达的数据挖掘技术并成功地应用在大规模文本比对领域上的创新产品。通过对文档关键语义片段的识别、检测,可检测出文档中存在的不当引用、过度以用,甚至是抄袭等现象,并计算出文档的引用率、复写率和自写率等重要指标,为各级论文评定、检测、发表机构提供论文评定和论文收录的检测依据。 该系统采用TONDA公司自主研发的核心算法技术,具有业内领先的检测速度。全文比对数据库由专业的期刊数据库、广泛的web互联网数据、TONDA共享数据库和用户自建库组成,保证了比对源的专业性和广泛性。VTTMS具备很高的实用性和易用性,自其成功研发以来,已经在全国范围内众多行业和部门得到了广泛使用,获得了高度的好评,取得了良好的口碑。 3 知识产权卫士-拷克网 http://www.copycheck.com.cn 拷克网成立于2009年,是专业的内容抄袭智能检测平台服务商,成立以来一直执行 “技术领先战略”,开创了具有国际领先水平的核心、高端、基础技术---互联网在线中文智能抄袭检测技术,作为一家拥有领先技术的服务商,我们致力于通过对技术的创新和应用,来满知识版权组织和个人的需要。 公司的技术核心是内容抄袭智能检测技术研究,以分词技术为基础,以结构智能方法论为指导,开发出文本语义结构化引擎、版式语义结构化引擎、行为语义分析引擎,由此构建了互联网内容抄袭智能检测服务平台。该服务平台主要提供:网站监控、数据萃取、信息标引、情报发现与分析、知识网络、行为语义分析等在线服务。 4 论文检测大师 http://www.check-paper.com/ 只支持 doc 类型文件上传!提交您的有效论文,请不要上传无用文档,每个IP仅有2次检测机会,您的检测结果将以word文档的方式发送到您的邮箱里。 5 中国搜文章照妖镜 http://www.zhongguosou.com/ 文章照妖镜不但可用来分析文章抄袭的程度,而且可用来检测自己的博客文章被别人复制、被别人疯狂传播的程度,帮你保护你博客的版权。 6 外文论文检测系统 www.turnitin.com 必杀招:智慧语料库技术+GradeMark™ +专利的 Peer Review ,在全世界90多个国家、超过7000所高等院校应用,每天检测10万篇论文。适用:英文论文抄袭检查 http://www.dustball.com/ 7 繁体论文检查网站: 网址:http://www.ppvs.org 网址:http://www.paper119.com/

5,139

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 Office开发/ VBA
社区管理员
  • Office开发/ VBA社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧