一次删除文档中所有表格
时间:2022-04-24 16:33:37
WORD长文档中,经常含有很多表格。有时候,我们需要把这些表格删除。当然,我们可以一个一个的选中再删除,但,如果你的文档中的表格很多,或是表格位置不固定,这种逐一删除的方法显然不可取。
今天给一段代码,能一次删除文档中所有表格。
实现方法
随便建一个有很多表格的文档:
表格的格式不一、内容不一。
现在我们来一次删除这些表格。
第一步:按[Alt]+F11,打开VBA窗口代码;
第二步:在VBA窗口中输入以下代码:
Sub Removetables()
Dim oTable As Table
For Each oTable In ActiveDocument.Tables
oTable.Delete
Next oTable
End Sub
如下图:
第三步:运行代码,所有的表格,不管格式如何、有无内容,都可一次删除,如下:
注意事项
1:带有VBA的文档保存:
保存时,会弹出如下提示:
此时,一定选择“否”,然后,选择保存位置与保存类型。
带有VBA的文档一定要保存为“启用宏的文档”*.docm“,否则宏会丢失。如上图:
2.如果你的电脑中按”[Alt]+F11“打不开VBA 窗口,则可以在”文件“菜单中选择”选项“,在”Word选项”窗口中的“自定义功能区”中勾选“开发工具”,如下图:
在“开发工具”菜单中,最左侧即是“visual Basic”,如下图:
标签:word排版,word教程,word文档,word教程
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Word中怎么删除文档中的线条
2022-08-31 22:27:07
![](https://img.aspxhome.com/file/2023/3/21913_0s.png)
如何为word文档添加行号
2023-12-02 14:12:43
![](https://img.aspxhome.com/file/2023/8/19328_0s.jpg)
word2010首页无页码如何设置?
2023-11-25 09:44:56
![](https://img.aspxhome.com/file/2023/8/18148_0s.jpg)
word中长破折号怎么打
2023-12-06 15:18:40
Win10打印文件出现挂起情况怎么办?打印文件出现挂起情况的解决方法
2023-06-04 21:39:19
![](https://img.aspxhome.com/file/2023/6/46406_0s.jpg)
WPS中荧光笔怎么使用
2023-07-24 23:42:16
![](https://img.aspxhome.com/file/2023/9/53549_0s.jpg)
word2003中怎么设置不自动创建绘图画布?
2023-12-01 23:36:52
![](https://img.aspxhome.com/file/2023/4/19244_0s.png)
Win10计算器在哪?Win10计算器快捷打开方法
2023-11-23 07:42:13
![](https://img.aspxhome.com/file/2023/2/49292_0s.png)
Win10 21H1更新KB5003637后任务栏不能在底部显示怎么办?
2023-12-08 12:49:04
![](https://img.aspxhome.com/file/2023/7/51277_0s.png)
无需求助第三方网站,office帮助是一个很好的培训课程
2023-11-07 17:55:46
![](https://img.aspxhome.com/file/2023/5/16685_0s.jpg)
Word功能区不见了怎么找回?
2023-12-08 02:07:53
![](https://img.aspxhome.com/file/2023/0/19460_0s.png)
更新到Win10需要用多少时间?
2023-11-23 18:39:09
![](https://img.aspxhome.com/file/2023/2/50132_0s.jpg)
Win10系统桌面壁纸无法设置怎么解决?
2023-11-25 10:27:43
![](https://img.aspxhome.com/file/2023/6/50576_0s.png)
在Word2010中取消自动生成超链接
2023-07-30 10:06:13
![](https://img.aspxhome.com/file/2023/0/21760_0s.jpg)
如何使用office生成PDF文件
2023-10-14 16:26:43
![](https://img.aspxhome.com/file/2023/5/16185_0s.jpg)
如何对win101903优化设置
2023-11-08 09:55:20
![](https://img.aspxhome.com/file/2023/5/48265_0s.jpg)
黑鲨一键重装win10教程 黑鲨win10系统安装教程
2023-11-24 23:09:44
![](https://img.aspxhome.com/file/2023/8/50768_0s.jpg)
Word排版技巧,参考辅助线帮助你快速对齐
2022-05-25 21:27:22
![](https://img.aspxhome.com/file/2023/8/22488_0s.gif)
Win10电脑怎么设置文件夹加密?
2023-12-14 14:39:04
![](https://img.aspxhome.com/file/2023/1/51881_0s.png)
Office安装过程中出错怎么解决?Office安装过程中出错的解决方法
2023-09-13 23:15:10
![](https://img.aspxhome.com/file/2023/2/16062_0s.jpg)