选择word中的表格VBA

  1. 打开开发工具

  2. 选择Visual Basic

  3. 插入代码

    Sub 选择word中的表格()
    Dim t As Table
    an = MsgBox("即将选择选区内所有表格,若无选区,则选择全文表格。", vbYesNo, "提示")
    If an - 6 Then Exit Sub
    Set rg = IIf(Selection.Type = wdSelectionIP, ActiveDocument.Content, Selection.Range)
    ActiveDocument.DeleteAllEditableRanges wdEditorEveryone
    For Each t In rg.Tables
    t.Range.Editors.Add wdEditorEveryone
    Next
    ActiveDocument.SelectAllEditableRanges wdEditorEveryone
    ActiveDocument.DeleteAllEditableRanges wdEditorEveryone
    End Sub

  1. 点击上面的运行按钮
相关推荐
simple_whu3 小时前
目录中不显示标题中间的软换行符Shift+Enter
word·office
weixin_416660074 小时前
2026年 DeepSeek 导出 Word 完全指南
word
珞瑜·7 小时前
【word】撰写文章中实用快捷键
word
骆驼爱记录8 小时前
Word目录:标题加粗页码不加粗技巧
自动化·word·excel·wps·新人首发
逐渐会飞2 天前
如何用python在word插入复选框
python·word
AndrewMe82113 天前
detailed-docx:一个能保住格式的 Word 文档操作库
开发语言·python·word
热爱生活的五柒3 天前
如何自动更新zotero?正文调换章节顺序后参考文献错乱无法刷新怎么办?
word·zotero·参考文献
骆驼爱记录4 天前
Word一键批量添加图章
自动化·word·excel·wps·新人首发
码路星河4 天前
SpringBoot3实战:优雅实现Word文档动态生成与下载
开发语言·c#·word
Eiceblue4 天前
通过 C# 读取 Word 表格数据:高效解析 + 导出为 CSV/TXT
开发语言·c#·word