设置Word表格的VBA代码
时间:2023-12-13 03:56:54
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)
猜你喜欢
Win10 1903内存使用爆满怎么解决?
![](https://img.aspxhome.com/file/2023/4/a305486_0s.jpg)
Word文字要怎么竖向排列?
![](https://img.aspxhome.com/file/2023/0/34850_0s.gif)
execl打印账本时设置打印区域的技巧
![](https://img.aspxhome.com/file/2023/7/42767_0s.jpg)
PPT怎么设计2018主题海报? ppt设计海报的教程
![](https://img.aspxhome.com/file/2023/10/a346124_0s.jpg )
Win8下不能打开IE10浏览器的解决办法
![](https://img.aspxhome.com/file/2023/29/a258316_0s.jpg)
word 是不是可以直接插入网页上的图片
![](https://img.aspxhome.com/file/2023/8/35708_0s.png)
Win10你需要关注的事项不兼容无法更新怎么办?
![](https://img.aspxhome.com/file/2023/26/a220619_0s.png)
Win7如何修改资源管理器左侧导航窗口的宽度
![](https://img.aspxhome.com/file/2023/27/a232988_0s.jpg)
CPU使用率老是100%怎么办?
![](https://img.aspxhome.com/file/2023/4/a305367_0s.jpg)
电脑突然黑屏怎么办?电脑突然黑屏的解决方法
![](https://img.aspxhome.com/file/2023/1/a276658_0s.png)
win7系统上的“快速启动栏”跑哪去了
Win7共享访问出现错误代码800704cf的解决方法
![](https://img.aspxhome.com/file/2023/1/a280966_0s.jpg)
win10盗贼之海连接不上服务器_win10盗贼之海连接不上服务器解决方法
![](https://img.aspxhome.com/file/2023/3/a295381_0s.jpg)
什么是CCleaner,CCleaner是否适合Mac?
![](https://img.aspxhome.com/file/2023/1/a211311_0s.jpeg)
打印机错误显示正在打印该怎么处理?
![](https://img.aspxhome.com/file/2023/6/a322356_0s.png)
如何找回Win7丢失的搜索功能
搜狗高速浏览器无法自动登录网站怎么办?
![](https://img.aspxhome.com/file/2023/30/a264375_0s.png)
实战WPS转义符在查找替换中的应用
![](https://img.aspxhome.com/file/2023/6/a164596_0s.jpg)
excel实现按颜色求和与计数函数
epic进不去怎么办_epic进不去游戏解决方法
![](https://img.aspxhome.com/file/2023/3/a296284_0s.jpg)