如何设置Word表格的VBA代码
时间:2023-01-12 05:16:14
今天小编教大家如何设置Word表格的VBA代码,用得着的朋友可以一起看看。VBA代码设置Word表格属性。
Dim i As Table, N As Integer
On Error Resume Next ’忽略错误
Application.ScreenUpdating = False ’关闭屏幕更新
For Each i In ActiveDocument.Tables ’在表格中循环
With i
.Style = "列表型 4" ’将所有表格设置为"列表型4"的样式
With .Borders ‘边框
.InsideLineStyle = wdLineStyleSingle ’设置内部边框线条
End With
With .Rows(1).Borders(wdBorderBottom) ‘第一行的底边框
.LineStyle = wdLineStyleDouble ‘双线型
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
If .Rows.Count > 1 Then ’ 如果表格行数大于1
If Len(.Cell(2, 1).Range) <= 2 Then ’如果第二行第一列不为空
With .Rows(2).Shading ’设置底纹
.Texture = wdTextureNone ’无底底纹
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorGray125
End With
End If
End If
For N = 2 To .Columns.Count ’从第二列到最后一列
.Columns(N).Select ’单元格对齐方式为中部居中
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
Next N
End With
Next i
Application.ScreenUpdating = True
以上的代码功能为:表格集合中的循环与对单元格边框的设置。
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
微软不再为Win8提供更新:请尽快升级到Win8.1或
![](https://img.aspxhome.com/file/2023/4/a309807_0s.jpg)
Win10开机提示:dfrgfat.exe应用程序错误的解决方法
![](https://img.aspxhome.com/file/2023/3/a297212_0s.jpg)
Win7系统添加新账户后怎样删除旧账户?
![](https://img.aspxhome.com/file/2023/5/a315285_0s.jpg)
win10系统第三方浏览器无法打开网页怎么办?
![](https://img.aspxhome.com/file/2023/4/a310512_0s.jpg)
家人共享:免费分享已经购买的 App
![](https://img.aspxhome.com/file/2023/9/a197789_0s.jpg)
Win10预览版10525开机黑屏的解决方法
![](https://img.aspxhome.com/file/2023/26/a226615_0s.jpg)
win10电脑截图怎么截长图?win10电脑截长图教程
![](https://img.aspxhome.com/file/2023/1/a271952_0s.png)
一键还原精灵怎么用?如何用一键还原精灵备份系统?
![](https://img.aspxhome.com/file/2023/9/a340624_0s.jpg)
win10录屏不全屏怎么办?win10录屏功能录全屏教程
![](https://img.aspxhome.com/file/2023/30/a266782_0s.jpg)
win7系统打不开LOL提示HostRecvWindow.exe损坏的图像的故障原因及解决方法
![](https://img.aspxhome.com/file/2023/28/a244543_0s.jpg)
win10桌面回收站不见了怎么办?win10桌面回收站不见的解决方法
![](https://img.aspxhome.com/file/2023/4/47804_0s.png)
Win7系统的最佳浏览效果的调节方法
![](https://img.aspxhome.com/file/2023/28/a246520_0s.png)
word打不开 并出现"向程序发送命令时出现问题"的对话框现象怎么解决
微信申诉失败是什么原因?微信申诉失败的解决方法
![](https://img.aspxhome.com/file/2023/8/a339732_0s.jpg)
win10哪个版本打游戏好?win10游戏性能分析
![](https://img.aspxhome.com/file/2023/26/a224219_0s.jpg)
Win7系统解决Rundll出错的图文教程
![](https://img.aspxhome.com/file/2023/28/a244494_0s.jpg)
去月球To The Moon Mac,这是一个悲伤的开始!
![](https://img.aspxhome.com/file/2023/9/a212829_0s.jpeg)
怎样恢复windows7系统误删的桌面图标具体步骤
![](https://img.aspxhome.com/file/2023/29/a257569_0s.jpg)
todesk和向日葵哪个好?todesk和向日葵比较介绍
![](https://img.aspxhome.com/file/2023/7/a327847_0s.jpg)
Win7系统修改回收站容量的方法
![](https://img.aspxhome.com/file/2023/27/a232790_0s.jpg)