列出单词文档中的短语列表 [英] Make a list of phrases from a word document

查看:103
本文介绍了列出单词文档中的短语列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一份包含数百个关键短语的文件。所有关键短语都以括号([)开头,以括号(]结束。我想在文档末尾添加所有这些关键短语的列表。 当我使用Excel和Access VBA时,我有
从未使用Word VBA。

I have a documents that has hundreds of key phrases. All key phrases start with a bracket ([) and end with a bracket (]). I like to append a list of all these key phrases at the end of the document.  While I do work with Excel and Access VBA, I have never worked with Word VBA.

谢谢你,

RickHbCa

推荐答案

这是一个宏:

Sub ListPhrases()
    Dim rng As Range
    Dim strPhrases As String
    Set rng = ActiveDocument.Content
    With rng.Find
        .ClearFormatting
        .MatchWildcards = True
        .Wrap = wdFindStop
        .Text = "\[*\]"
        Do While .Execute
            strPhrases = strPhrases & vbCr & rng.Text
        Loop
    End With
    ActiveDocument.Content.InsertAfter strPhrases
End Sub

如果你不想要要在列表中加入[和],请更改行

If you don't want to include the [ and ] in the list, change the line

    ActiveDocument.Content.InsertAfter strPhrases

    ActiveDocument.Content.InsertAfter strPhrases

    ActiveDocument.Content.InsertAfter替换(替换(strPhrases," [",""),"]","")

    ActiveDocument.Content.InsertAfter Replace(Replace(strPhrases, "[", ""), "]", "")


这篇关于列出单词文档中的短语列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆