wrjc1hod 发表于 2024-7-3 23:29:31

用Chat AI回答,删除Word文档内含有固定文字的段落


    <h2 style="color: black; text-align: left; margin-bottom: 10px;">示例,<span style="color: black;">每一个</span>段落含有“阅读”两个字</h2>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">需求1:删除含有固定文字的段落</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Chat AI引导如下:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Word有固定一个段落含有阅读两字,有<span style="color: black;">非常多</span>个<span style="color: black;">这般</span>的段落,我<span style="color: black;">必须</span>删除含有“阅读”两字所在的段落,麻烦给我宏代码</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://pic4.zhimg.com/80/v2-5926246a08273760b82d8011bd136e5f_720w.webp" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">AI回答如下:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">当然<span style="color: black;">能够</span>!以下是一个<span style="color: black;">能够</span>删除<span style="color: black;">包括</span>“阅读”两字所在段落的Word宏代码:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">```vba</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Sub 删除含有阅读两字的段落()</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> Dim rng As Range</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> Dim para As Paragraph</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 设置要<span style="color: black;">查询</span>的<span style="color: black;">重要</span>词</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> Dim keyword As String</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> keyword = "阅读"</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 从开头<span style="color: black;">起始</span><span style="color: black;">查询</span><span style="color: black;">每一个</span>段落</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> For Each para In ActiveDocument.Paragraphs</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Set rng = para.Range</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> <span style="color: black;">查询</span>段落中<span style="color: black;">是不是</span>含有<span style="color: black;">重要</span>词</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> If InStr(1, rng.Text, keyword, vbTextCompare) &gt; 0 Then</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 删除<span style="color: black;">包括</span><span style="color: black;">重要</span>词的段落</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> rng.Delete</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> End If</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> Next para</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">End Sub</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">```</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">要<span style="color: black;">运用</span>这个宏代码,请<span style="color: black;">根据</span>以下<span style="color: black;">过程</span>操作:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1. 打开你想要删除<span style="color: black;">包括</span>“阅读”两字段落的Word文档。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2. 按下`Alt` + `F11`,打开Visual Basic for Applications(VBA)编辑器。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3. 在左侧的项目资源管理器窗格中,找到你的文档名<span style="color: black;">叫作</span>,并双击打开它。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">4. 在打开的模块中,粘贴<span style="color: black;">以上</span>宏代码。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">5. 按下`F5`运行宏代码,<span style="color: black;">或</span>关闭VBA编辑器并在Word界面中<span style="color: black;">运用</span>快捷键`Alt` + `F8`<span style="color: black;">选取</span>宏并运行。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">这般</span>,宏代码将会遍历文档中的<span style="color: black;">每一个</span>段落,删除<span style="color: black;">包括</span>“阅读”两字的段落。请<span style="color: black;">重视</span>,在运行宏之前,最好先备份一下你的文档,以防不小心删除了不想删除的内容。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">期盼</span>这<span style="color: black;">能够</span><span style="color: black;">帮忙</span>到你!如有其他问题,请随时提问。</p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">需求2:不删除段落了,改为含有固定字所在段落的字号都缩小</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Chat AI引导如下:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Word有固定一个段落含有阅读两字,有<span style="color: black;">非常多</span>个<span style="color: black;">这般</span>的段落,我<span style="color: black;">必须</span>缩小含有“阅读”两字所在的段落的字号,都要比原来小2个字号,麻烦给我宏代码</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://pic2.zhimg.com/80/v2-b2d2451eda64f0ca68249c7d154a2701_720w.webp" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">AI回答如下:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">当然<span style="color: black;">能够</span>!以下是一个<span style="color: black;">能够</span>缩小<span style="color: black;">包括</span>“阅读”两字所在段落字号的Word宏代码:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">```vba</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Sub 缩小含有阅读两字的段落字号()</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> Dim rng As Range</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> Dim para As Paragraph</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 设置要<span style="color: black;">查询</span>的<span style="color: black;">重要</span>词</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> Dim keyword As String</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> keyword = "阅读"</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 从开头<span style="color: black;">起始</span><span style="color: black;">查询</span><span style="color: black;">每一个</span>段落</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">For Each para In ActiveDocument.Paragraphs</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> Set rng = para.Range</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> <span style="color: black;">查询</span>段落中<span style="color: black;">是不是</span>含有<span style="color: black;">重要</span>词</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> If InStr(1, rng.Text, keyword, vbTextCompare) &gt; 0 Then</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 缩小段落字号</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> rng.Font.Size = rng.Font.Size - 2</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> End If</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> Next para</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">End Sub</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">```</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">要<span style="color: black;">运用</span>这个宏代码,请<span style="color: black;">根据</span>以下<span style="color: black;">过程</span>操作:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1. 打开你想要缩小<span style="color: black;">包括</span>“阅读”两字段落字号的Word文档。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2. 按下`Alt` + `F11`,打开Visual Basic for Applications(VBA)编辑器。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3. 在左侧的项目资源管理器窗格中,找到你的文档名<span style="color: black;">叫作</span>,并双击打开它。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">4. 在打开的模块中,粘贴<span style="color: black;">以上</span>宏代码。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">5. 按下`F5`运行宏代码,<span style="color: black;">或</span>关闭VBA编辑器并在Word界面中<span style="color: black;">运用</span>快捷键`Alt` + `F8`<span style="color: black;">选取</span>宏并运行。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">这般</span>,宏代码将会遍历文档中的<span style="color: black;">每一个</span>段落,<span style="color: black;">倘若</span>段落中<span style="color: black;">包括</span>“阅读”两字,则将该段落的字号缩小2个字号。请<span style="color: black;">重视</span>,在运行宏之前,最好先备份一下你的文档,以防不小心修改了不想修改的内容。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">期盼</span>这<span style="color: black;">能够</span><span style="color: black;">帮忙</span>到你!如有其他问题,请随时提问。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">最后说下</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">需求引导比较<span style="color: black;">要紧</span>,能够让AI清晰得到指令<span style="color: black;">就可</span>。</p>




wrjc1hod 发表于 2024-10-10 23:07:13

你的留言真是温暖如春,让我感受到了无尽的支持与鼓励。

7wu1wm0 发表于 2024-10-11 13:07:49

论坛的成功是建立在我们诚恳、务实、高效、创新和团结合作基础上,我们要把这种精神传递下去。

4zhvml8 发表于 6 天前

你的努力一定会被看见,相信自己,加油。

j8typz 发表于 4 天前

顶楼主,说得太好了!

4lqedz 发表于 3 天前

你的话语如春风拂面,让我心生暖意。
页: [1]
查看完整版本: 用Chat AI回答,删除Word文档内含有固定文字的段落