|
我想把 WORD中 符合条件的表格变成18CM宽本例中就是最后一个 表格,二行三列为 点击率的表,变成18CM
不知 如何写判断语句
副本.rar
(14.96 KB, 下载次数: 15)
下面代码这样的全部变成18CM
- Sub select_alltables调整18厘米表格()
- Dim mytable As Table
- Application.ScreenUpdating = False
-
- For Each mytable In ActiveDocument.Tables
- mytable.Range.Editors.Add wdEditorEveryone '选中整个表格
- With mytable
- mytable.Rows.Alignment = wdAlignRowCenter '整个表格水平居中
- mytable.PreferredWidth = CentimetersToPoints(18) '整个表格宽度为18CM
- End With
- Next
-
- ActiveDocument.SelectAllEditableRanges (wdEditorEveryone) '必须要的:选中全部表格区域
- ActiveDocument.DeleteAllEditableRanges (wdEditorEveryone) '必须要的:删除区域选中状态
- Application.ScreenUpdating = True
- End Sub
复制代码
加上判断语句
If mytable.Cell(2, 3).Range.Text = "点击率" Then
判断表格就不执行
If mytable.Cell(2, 3).Range = "点击率" Then
判断表格就不执行
换成 下面,就显示 类型不匹配
If mytable.Cell(2, 3) = "点击率" Then
- Sub select_alltables调整18厘米表格()
- Dim mytable As Table
- Application.ScreenUpdating = False
-
- For Each mytable In ActiveDocument.Tables
- If mytable.Cell(2, 3).Range.Text = "点击率" Then
- mytable.Range.Editors.Add wdEditorEveryone '选中整个表格
- With mytable
- mytable.Rows.Alignment = wdAlignRowCenter '整个表格水平居中
- mytable.PreferredWidth = CentimetersToPoints(18) '整个表格宽度为18CM
- End With
- End If
- Next
-
- ActiveDocument.SelectAllEditableRanges (wdEditorEveryone) '必须要的:选中全部表格区域
- ActiveDocument.DeleteAllEditableRanges (wdEditorEveryone) '必须要的:删除区域选中状态
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|