- 资源积分
-
- 下载点
- 个
- 珍品钻
- 颗
- 宣传值
- 次
- 阅读权限
- 170
- 在线时间
- 小时
- 最后登录
- 1970-1-1
- 注册时间
- 2013-5-28
|
- Sub 批量修改表格边框颜色()
- Dim strTitle As String
- Dim strMsg As String
- Dim Style As VbMsgBoxStyle
- Dim Response As VbMsgBoxResult
- Dim objTable As Table
- Dim objBorderStyle As WdLineStyle
- Dim objBorderWidth As WdLineWidth
- Dim objBorderColor As WdColor
- Dim objArray As Variant
- Dim n As Long
- Dim i As Long
- '可以将下面的值修改为想要的样式,线宽和颜色
- objBorderStyle = wdLineStyleSingle
- objBorderWidth = wdLineWidth075pt
- objBorderColor = wdColorDarkBlue
- strTitle = "给文档中所有表格设置统一的边框"
- '如果当前文档中包含有表格
- If ActiveDocument.Tables.Count > 0 Then
- strMsg = "给当前文档所有表格设置统一边框." & vbCr & vbCr & "想继续吗?"
- Style = vbYesNo + vbQuestion
- Response = MsgBox(strMsg, Style,strTitle)
- If Response <> vbYes Then Exit Sub
- Else
- '当前文档中没有找到表格
- MsgBox "文档中没有表格.",vbInformation, strTitle
- Exit Sub
- End If
- '使用要更改的边框定义数组
- '这里不包括对角线边框
- objArray = Array(wdBorderTop, _
- wdBorderLeft, _
- wdBorderBottom, _
- wdBorderRight, _
- wdBorderHorizontal, _
- wdBorderVertical)
- For Each objTable In ActiveDocument.Tables
- '统计表格数量
- n = n + 1
- With objTable
- For i = LBound(objArray) To UBound(objArray)
- '如果仅1行且wdBorderHorizontal
- If .Rows.Count = 1 And objArray(i) = wdBorderHorizontal Then GoTo Skip
- '如果仅1列且wdBorderVertical
- If .Columns.Count = 1 And objArray(i) = wdBorderVertical Then GoTo Skip
- With .Borders(objArray(i))
- .LineStyle = objBorderStyle
- .LineWidth = objBorderWidth
- .Color = objBorderColor
- End With
- Skip:
- Next i
- End With
- Next objTable
- MsgBox "完成对" & n & "个表格设置边框.",vbOKOnly, strTitle
- End Sub
复制代码 以上代码中的:
objBorderStyle = wdLineStyleSingle (为边框样式)指定对象的边框样式。名称 | 值 | 说明 | | wdLineStyleDashDot | 5 | 划线后跟点。 | | wdLineStyleDashDotDot | 6 | 划线后跟两个点。 | | wdLineStyleDashDotStroked | 20 | 划线后跟粗点,使边框的外观类似于理发店招牌。 | | wdLineStyleDashLargeGap | 4 | 划线后跟大间隙。 | | wdLineStyleDashSmallGap | 3 | 划线后跟小间隙。 | | wdLineStyleDot | 2 | 点。 | | wdLineStyleDouble | 7 | 双实线。 | | wdLineStyleDoubleWavy | 19 | 波浪型双实线。 | | wdLineStyleEmboss3D | 21 | 边框看起来具有 3D 浮现外观。 | | wdLineStyleEngrave3D | 22 | 边框看起来具有 3D 阴文外观。 | | wdLineStyleInset | 24 | 边框呈现凹进效果。 | | wdLineStyleNone | 0 | 无边框。 | | wdLineStyleOutset | 23 | 边框呈现凸起效果。 | | wdLineStyleSingle | 1 | 单实线 | | wdLineStyleSingleWavy | 18 | 波浪型单实线。 | | wdLineStyleThickThinLargeGap | 16 | 里面是一条粗实线,外面是一条细实线,两条线的间隙较大。 | | wdLineStyleThickThinMedGap | 13 | 里面是一条粗实线,外面是一条细实线,两条线的间隙中等。 | | wdLineStyleThickThinSmallGap | 10 | 里面是一条粗实线,外面是一条细实线,两条线的间隙较小。 | | wdLineStyleThinThickLargeGap | 15 | 里面是一条细实线,外面是一条粗实线,两条线的间隙较大。 | | wdLineStyleThinThickMedGap | 12 | 里面是一条细实线,外面是一条粗实线,两条线的间隙中等。 | | wdLineStyleThinThickSmallGap | 9 | 里面是一条细实线,外面是一条粗实线,两条线的间隙较小。 | | wdLineStyleThinThickThinLargeGap | 17 | 最里面是一条细实线,其次是一条粗实线,最外面是一条细实线,所有线之间的间隙较大。 | | wdLineStyleThinThickThinMedGap | 14 | 最里面是一条细实线,其次是一条粗实线,最外面是一条细实线,所有线之间的间隙中等。 | | wdLineStyleThinThickThinSmallGap | 11 | 最里面一条细实线,其次一条粗实线,最外面是一条细实线,所有线之间的间隙较小。 | | wdLineStyleTriple | 8 | 三条细实线。 | objBorderWidth = wdLineWidth075pt (为边框线宽)指定对象边框的宽度。名称 | 值 | 说明 | | wdLineWidth025pt | 2 | 0.25 磅。 | | wdLineWidth050pt | 4 | 0.50 磅。 | | wdLineWidth075pt | 6 | 0.75 磅。 | | wdLineWidth100pt | 8 | 1.00 点。 默认值。 | | wdLineWidth150pt | 12 | 1.50 磅。 | | wdLineWidth225pt | 18 | 2.25 磅。 | | wdLineWidth300pt | 24 | 3.00 磅。 | | wdLineWidth450pt | 36 | 4.50 磅。 | | wdLineWidth600pt | 48 | 6.00 磅。 | objBorderColor = wdColorDarkBlue (为边框颜色)其中代码颜色参考如下:指定要应用的 24 位颜色。
名称 | 十进制 | 说明 | HEX | R | G | B | | wdColorAqua | 13421619 | 水绿色 | #33CCCC | 51 | 204 | 204 | | wdColorAutomatic | -16777216 | 自动颜色;default;通常为黑色 | #000000 | 0 | 0 | 0 | | wdColorBlack | 0 | 黑色 | #000000 | 0 | 0 | 0 | | wdColorBlue | 16711680 | 蓝色 | #0000FF | 0 | 0 | 255 | | wdColorBlueGray | 10053222 | 蓝灰色 | #666699 | 102 | 102 | 153 | | wdColorBrightGreen | 65280 | 亮绿色 | #00FF00 | 0 | 255 | 0 | | wdColorBrown | 13209 | 深红色 | #993300 | 153 | 51 | 0 | | wdColorDarkBlue | 8388608 | 深蓝色 | #000080 | 0 | 0 | 128 | | wdColorDarkGreen | 13056 | 深绿色 | #003300 | 0 | 51 | 0 | | wdColorDarkRed | 128 | 深红色 | #800000 | 128 | 0 | 0 | | wdColorDarkTeal | 6697728 | 深青色 | #003366 | 0 | 51 | 102 | | wdColorDarkYellow | 32896 | 深黄色 | #808000 | 128 | 128 | 0 | | wdColor使用 | 52479 | 金色 | #FFCC00 | 255 | 204 | 0 | | wdColorGray05 | 15987699 | 05% 灰色底纹 | #F3F3F3 | 243 | 243 | 243 | | wdColorGray10 | 15132390 | 10% 灰色底纹 | #E6E6E6 | 230 | 230 | 230 | | wdColorGray125 | 14737632 | 125% 灰色底纹 | #E0E0E0 | 224 | 224 | 224 | | wdColorGray15 | 14277081 | 15% 灰色底纹 | #D9D9D9 | 217 | 217 | 217 | | wdColorGray20 | 13421772 | 20% 灰色底纹 | #CCCCCC | 204 | 204 | 204 | | wdColorGray25 | 12632256 | 25% 灰色底纹 | #C0C0C0 | 192 | 192 | 192 | | wdColorGray30 | 11776947 | 30% 灰色底纹 | #B3B3B3 | 179 | 179 | 179 | | wdColorGray35 | 10921638 | 35% 灰色底纹 | #A6A6A6 | 166 | 166 | 166 | | wdColorGray375 | 10526880 | 375% 灰色底纹 | #A0A0A0 | 160 | 160 | 160 | | wdColorGray40 | 10066329 | 40% 灰色底纹 | #999999 | 153 | 153 | 153 | | wdColorGray45 | 9211020 | 45% 灰色底纹 | #8C8C8C | 140 | 140 | 140 | | wdColorGray50 | 8421504 | 50% 灰色底纹 | #808080 | 128 | 128 | 128 | | wdColorGray55 | 7566195 | 55% 灰色底纹 | #737373 | 115 | 115 | 115 | | wdColorGray60 | 6710886 | 60% 灰色底纹 | #666666 | 102 | 102 | 102 | | wdColorGray625 | 6316128 | 625% 灰色底纹 | #606060 | 96 | 96 | 96 | | wdColorGray65 | 5855577 | 65% 灰色底纹 | #595959 | 89 | 89 | 89 | | wdColorGray70 | 5000268 | 70% 灰色底纹 | #4C4C4C | 76 | 76 | 76 | | wdColorGray75 | 4210752 | 75% 灰色底纹 | #404040 | 64 | 64 | 64 | | wdColorGray80 | 3355443 | 80% 灰色底纹 | #333333 | 51 | 51 | 51 | | wdColorGray85 | 2500134 | 85% 灰色底纹 | #262626 | 38 | 38 | 38 | | wdColorGray875 | 2105376 | 875% 灰色底纹 | #202020 | 32 | 32 | 32 | | wdColorGray90 | 1644825 | 90% 灰色底纹 | #191919 | 25 | 25 | 25 | | wdColorGray95 | 789516 | 95% 灰色底纹 | #0C0C0C | 12 | 12 | 12 | | wdColorGreen | 32768 | 绿色 | #008000 | 0 | 128 | 0 | | wdColorIndigo | 10040115 | Indigo 颜色 | #333399 | 51 | 51 | 153 | | wdColorColorColorender | 16751052 | 淡紫色 | #CC99FF | 204 | 153 | 255 | | wdColorLightBlue | 16737843 | 浅蓝色 | #3366FF | 51 | 102 | 255 | | wdColorLightGreen | 13434828 | 浅绿色 | #CCFFCC | 204 | 255 | 204 | | wdColorLightOrange | 39423 | 浅橙色 | #FF9900 | 255 | 153 | 0 | | wdColorLightTurquoise | 16777164 | 浅青绿色 | #CCFFFF | 204 | 255 | 255 | | wdColorLightYellow | 10092543 | 浅黄色 | #FFFF99 | 255 | 255 | 153 | | wdColorLime | 52377 | 橙色 | #99CC00 | 153 | 204 | 0 | | wdColorOliveGreen | 13107 | 橄榄色 | #333300 | 51 | 51 | 0 | | wdColorOrange | 26367 | 橙色 | #FF6600 | 255 | 102 | 0 | | wdColorPaleBlue | 16764057 | 淡蓝色 | #99CCFF | 153 | 204 | 255 | | wdColorPink | 16711935 | 粉色颜色 | #FF00FF | 255 | 0 | 255 | | wdColorPlum | 6697881 | 花红色 | #993366 | 153 | 51 | 102 | | wdColorRed | 255 | 红色 | #FF0000 | 255 | 0 | 0 | | wdColorRose | 13408767 | 花色 | #FF99CC | 255 | 153 | 204 | | wdColorSeaGreen | 6723891 | 深绿色 | #339966 | 51 | 153 | 102 | | wdColorSkyBlue | 16763904 | 天蓝色 | #00CCFF | 0 | 204 | 255 | | wdColorTan | 10079487 | Tan 颜色 | #FFCC99 | 255 | 204 | 153 | | wdColorTeal | 8421376 | 青色 | #008080 | 0 | 128 | 128 | | wdColorTurquoise | 16776960 | 青绿色 | #00FFFF | 0 | 255 | 255 | | wdColorViolet | 8388736 | 紫色 | #800080 | 128 | 0 | 128 | | wdColorWhite | 16777215 | 白色 | #FFFFFF | 255 | 255 | 255 | | wdColorYellow | 65535 | 黄色 | #FFFF00 | 255 | 255 | 0 |
|
|