因此,我有一些InlineShapes驻留在WORD表中。我试图将所有InlineShapes放在表格的第三栏中,并在它们周围应用边框。不幸的是,对于我的一生,我无法弄清楚如何将其应用于图片而不是表格的单元格。
这是我的代码:
ActiveDocument.Tables(1).Columns(3).Select
For Each iPicture In Selection.InlineShapes
With iPicture
.Borders.Enable = True
.Borders.OutsideColor = wdColorRed
.Borders.OutsideLineWidth = wdLineWidth150pt
.Borders.OutsideLineStyle = wdLineStyleSingle
End With
Next
我还尝试将以下代码放入其中,With iPicture
但似乎没有什么区别,仍然在单元格周围绘制边框而不是图片。
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
.Color = wdColorRed
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
.Color = wdColorRed
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
.Color = wdColorRed
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
.Color = wdColorRed
End With
我的测试尚无定论。一些物体有一个边界。与其他人一起,将边框应用于单元格。
但是,在所有后一种情况下,如果我在对象之后(单元格的末尾)放置一个空格,则边框将正确应用。
因此,我怀疑这与单元格末尾的隐藏段落标记有关,该标记有时以某种方式被InlineShape
对象拾取。
InlineShape
如果单元格中的字符数小于或等于2(仅包含InlineShape
和单元格结束标记),则下面的示例代码在每个字符之后添加一个空格。
插入空格会使选择折叠。因此,表和选定的列在开头被记录,并且在该操作之后重新选择了该列。如果空间对您来说是个问题,请添加创建边界后经过并删除的代码。
Sub BorderInlineShapes()
Dim sel As Word.Selection
Dim ils As Word.InlineShape
Dim rng As Word.Range
Dim colNr As Long
Dim tbl As Word.Table
Set sel = Selection
If sel.Tables.Count = 1 Then
Set tbl = sel.Tables(1)
colNr = sel.Information(wdEndOfRangeColumnNumber)
For Each ils In sel.InlineShapes
If Not ils.Borders.Enable Then ils.Borders.Enable = True
If ils.Range.Cells.Count > 0 Then
Set rng = ils.Range
If rng.Cells(1).Range.Characters.Count <= 2 Then
rng.InsertAfter " "
tbl.Columns(colNr).Select
End If
End If
ils.Borders.OutsideColor = wdColorRed
ils.Borders.OutsideLineWidth = wdLineWidth075pt
Next
End If
End Sub
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句