VBA唏嘘戏——简单单元格的设定(实例)
Posted 眸眸
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VBA唏嘘戏——简单单元格的设定(实例)相关的知识,希望对你有一定的参考价值。
由于有很多个Word文件,所以应用宏会更加方便排版,而且版式较为统一。
Sub 设置列宽() \' \' 设置列宽宏 \' \' ActiveDocument.Tables(1).Cell(7, 2).Width = 45 \'将Word表格的第7行第2列(即B7单元格)的宽度设为45 ActiveDocument.Tables(1).Cell(7, 3).Width = 30 ActiveDocument.Tables(1).Cell(7, 4).Width = 117 ActiveDocument.Tables(1).Cell(7, 5).Width = 33 ActiveDocument.Tables(1).Cell(7, 6).Width = 30 ActiveDocument.Tables(1).Cell(7, 7).Width = 30 ActiveDocument.Tables(1).Cell(7, 8).Width = 30 ActiveDocument.Tables(1).Cell(7, 9).Width = 57 ActiveDocument.Tables(1).Cell(7, 10).Width = 39 ActiveDocument.Tables(1).Cell(7, 11).Width = 39 ActiveDocument.Tables(1).Cell(7, 12).Width = 60 ActiveDocument.Tables(1).Cell(7, 13).Width = 33 ActiveDocument.Tables(1).Cell(7, 14).Width = 30 ActiveDocument.Tables(1).Cell(7, 15).Width = 30 ActiveDocument.Tables(1).Cell(7, 16).Width = 30 ActiveDocument.Tables(1).Cell(7, 17).Width = 70.5 ActiveDocument.Tables(1).Cell(7, 17).Range.Text = "" \'将Word的表格第7行第17列单元格(Q7单元格)的值设置为空 ActiveDocument.Tables(1).Cell(8, 2).Width = 45 ActiveDocument.Tables(1).Cell(8, 3).Width = 30 ActiveDocument.Tables(1).Cell(8, 4).Width = 117 ActiveDocument.Tables(1).Cell(8, 5).Width = 33 ActiveDocument.Tables(1).Cell(8, 6).Width = 30 ActiveDocument.Tables(1).Cell(8, 7).Width = 30 ActiveDocument.Tables(1).Cell(8, 8).Width = 30 ActiveDocument.Tables(1).Cell(8, 9).Width = 57 ActiveDocument.Tables(1).Cell(8, 10).Width = 39 ActiveDocument.Tables(1).Cell(8, 11).Width = 39 ActiveDocument.Tables(1).Cell(8, 12).Width = 60 ActiveDocument.Tables(1).Cell(8, 13).Width = 33 ActiveDocument.Tables(1).Cell(8, 14).Width = 30 ActiveDocument.Tables(1).Cell(8, 15).Width = 30 ActiveDocument.Tables(1).Cell(8, 16).Width = 30 ActiveDocument.Tables(1).Cell(8, 17).Width = 70.5 ActiveDocument.Tables(1).Cell(8, 17).Range.Text = "" ActiveDocument.Tables(1).Cell(9, 2).Width = 45 ActiveDocument.Tables(1).Cell(9, 3).Width = 30 ActiveDocument.Tables(1).Cell(9, 4).Width = 117 ActiveDocument.Tables(1).Cell(9, 5).Width = 33 ActiveDocument.Tables(1).Cell(9, 6).Width = 30 ActiveDocument.Tables(1).Cell(9, 7).Width = 30 ActiveDocument.Tables(1).Cell(9, 8).Width = 30 ActiveDocument.Tables(1).Cell(9, 9).Width = 57 ActiveDocument.Tables(1).Cell(9, 10).Width = 39 ActiveDocument.Tables(1).Cell(9, 11).Width = 39 ActiveDocument.Tables(1).Cell(9, 12).Width = 60 ActiveDocument.Tables(1).Cell(9, 13).Width = 33 ActiveDocument.Tables(1).Cell(9, 14).Width = 30 ActiveDocument.Tables(1).Cell(9, 15).Width = 30 ActiveDocument.Tables(1).Cell(9, 16).Width = 30 ActiveDocument.Tables(1).Cell(9, 17).Width = 70.5 ActiveDocument.Tables(1).Cell(9, 17).Range.Text = "" ActiveDocument.Tables(1).Cell(10, 2).Width = 45 ActiveDocument.Tables(1).Cell(10, 3).Width = 30 ActiveDocument.Tables(1).Cell(10, 4).Width = 117 ActiveDocument.Tables(1).Cell(10, 5).Width = 33 ActiveDocument.Tables(1).Cell(10, 6).Width = 30 ActiveDocument.Tables(1).Cell(10, 7).Width = 30 ActiveDocument.Tables(1).Cell(10, 8).Width = 30 ActiveDocument.Tables(1).Cell(10, 9).Width = 57 ActiveDocument.Tables(1).Cell(10, 10).Width = 39 ActiveDocument.Tables(1).Cell(10, 11).Width = 39 ActiveDocument.Tables(1).Cell(10, 12).Width = 60 ActiveDocument.Tables(1).Cell(10, 13).Width = 33 ActiveDocument.Tables(1).Cell(10, 14).Width = 30 ActiveDocument.Tables(1).Cell(10, 15).Width = 30 ActiveDocument.Tables(1).Cell(10, 16).Width = 30 ActiveDocument.Tables(1).Cell(10, 17).Width = 70.5 ActiveDocument.Tables(1).Cell(10, 17).Range.Text = "" ActiveDocument.Tables(1).Cell(11, 2).Width = 45 ActiveDocument.Tables(1).Cell(11, 3).Width = 30 ActiveDocument.Tables(1).Cell(11, 4).Width = 117 ActiveDocument.Tables(1).Cell(11, 5).Width = 33 ActiveDocument.Tables(1).Cell(11, 6).Width = 30 ActiveDocument.Tables(1).Cell(11, 7).Width = 30 ActiveDocument.Tables(1).Cell(11, 8).Width = 30 ActiveDocument.Tables(1).Cell(11, 9).Width = 57 ActiveDocument.Tables(1).Cell(11, 10).Width = 39 ActiveDocument.Tables(1).Cell(11, 11).Width = 39 ActiveDocument.Tables(1).Cell(11, 12).Width = 60 ActiveDocument.Tables(1).Cell(11, 13).Width = 33 ActiveDocument.Tables(1).Cell(11, 14).Width = 30 ActiveDocument.Tables(1).Cell(11, 15).Width = 30 ActiveDocument.Tables(1).Cell(11, 16).Width = 30 ActiveDocument.Tables(1).Cell(11, 17).Width = 70.5 ActiveDocument.Tables(1).Cell(11, 17).Range.Text = "" ActiveDocument.Tables(1).Cell(12, 2).Width = 45 ActiveDocument.Tables(1).Cell(12, 3).Width = 30 ActiveDocument.Tables(1).Cell(12, 4).Width = 117 ActiveDocument.Tables(1).Cell(12, 5).Width = 33 ActiveDocument.Tables(1).Cell(12, 6).Width = 30 ActiveDocument.Tables(1).Cell(12, 7).Width = 30 ActiveDocument.Tables(1).Cell(12, 8).Width = 30 ActiveDocument.Tables(1).Cell(12, 9).Width = 57 ActiveDocument.Tables(1).Cell(12, 10).Width = 39 ActiveDocument.Tables(1).Cell(12, 11).Width = 39 ActiveDocument.Tables(1).Cell(12, 12).Width = 60 ActiveDocument.Tables(1).Cell(12, 13).Width = 33 ActiveDocument.Tables(1).Cell(12, 14).Width = 30 ActiveDocument.Tables(1).Cell(12, 15).Width = 30 ActiveDocument.Tables(1).Cell(12, 16).Width = 30 ActiveDocument.Tables(1).Cell(12, 17).Width = 70.5 ActiveDocument.Tables(1).Cell(12, 17).Range.Text = "" ActiveDocument.Tables(1).Cell(13, 2).Width = 45 ActiveDocument.Tables(1).Cell(13, 3).Width = 30 ActiveDocument.Tables(1).Cell(13, 4).Width = 117 ActiveDocument.Tables(1).Cell(13, 5).Width = 33 ActiveDocument.Tables(1).Cell(13, 6).Width = 30 ActiveDocument.Tables(1).Cell(13, 7).Width = 30 ActiveDocument.Tables(1).Cell(13, 8).Width = 30 ActiveDocument.Tables(1).Cell(13, 9).Width = 57 ActiveDocument.Tables(1).Cell(13, 10).Width = 39 ActiveDocument.Tables(1).Cell(13, 11).Width = 39 ActiveDocument.Tables(1).Cell(13, 12).Width = 60 ActiveDocument.Tables(1).Cell(13, 13).Width = 33 ActiveDocument.Tables(1).Cell(13, 14).Width = 30 ActiveDocument.Tables(1).Cell(13, 15).Width = 30 ActiveDocument.Tables(1).Cell(13, 16).Width = 30 ActiveDocument.Tables(1).Cell(13, 17).Width = 70.5 ActiveDocument.Tables(1).Cell(13, 17).Range.Text = "" ActiveDocument.Tables(1).Cell(14, 2).Width = 45 ActiveDocument.Tables(1).Cell(14, 3).Width = 30 ActiveDocument.Tables(1).Cell(14, 4).Width = 117 ActiveDocument.Tables(1).Cell(14, 5).Width = 33 ActiveDocument.Tables(1).Cell(14, 6).Width = 30 ActiveDocument.Tables(1).Cell(14, 7).Width = 30 ActiveDocument.Tables(1).Cell(14, 8).Width = 30 ActiveDocument.Tables(1).Cell(14, 9).Width = 57 ActiveDocument.Tables(1).Cell(14, 10).Width = 39 ActiveDocument.Tables(1).Cell(14, 11).Width = 39 ActiveDocument.Tables(1).Cell(14, 12).Width = 60 ActiveDocument.Tables(1).Cell(14, 13).Width = 33 ActiveDocument.Tables(1).Cell(14, 14).Width = 30 ActiveDocument.Tables(1).Cell(14, 15).Width = 30 ActiveDocument.Tables(1).Cell(14, 16).Width = 30 ActiveDocument.Tables(1).Cell(14, 17).Width = 70.5 ActiveDocument.Tables(1).Cell(14, 17).Range.Text = "" ActiveDocument.Tables(1).Cell(15, 2).Width = 45 ActiveDocument.Tables(1).Cell(15, 3).Width = 30 ActiveDocument.Tables(1).Cell(15, 4).Width = 117 ActiveDocument.Tables(1).Cell(15, 5).Width = 33 ActiveDocument.Tables(1).Cell(15, 6).Width = 30 ActiveDocument.Tables(1).Cell(15, 7).Width = 30 ActiveDocument.Tables(1).Cell(15, 8).Width = 30 ActiveDocument.Tables(1).Cell(15, 9).Width = 57 ActiveDocument.Tables(1).Cell(15, 10).Width = 39 ActiveDocument.Tables(1).Cell(15, 11).Width = 39 ActiveDocument.Tables(1).Cell(15, 12).Width = 60 ActiveDocument.Tables(1).Cell(15, 13).Width = 33 ActiveDocument.Tables(1).Cell(15, 14).Width = 30 ActiveDocument.Tables(1).Cell(15, 15).Width = 30 ActiveDocument.Tables(1).Cell(15, 16).Width = 30 ActiveDocument.Tables(1).Cell(15, 17).Width = 70.5 ActiveDocument.Tables(1).Cell(15, 17).Range.Text = "" ActiveDocument.Tables(1).AllowAutoFit = False End Sub
以上是关于VBA唏嘘戏——简单单元格的设定(实例)的主要内容,如果未能解决你的问题,请参考以下文章