如何从内联形状中删除边框 [英] How to remove a border from an inline shape
问题描述
我在 Word 2010 上使用 VBA.
I am working in VBA on Word 2010.
我有一些代码可以将边框添加到工作正常的 inlineshape,但我需要能够删除边框,但这似乎不起作用.我已经搜索过这个网站,但除此之外找不到任何其他内容:
I have some code to add borders to an inlineshape which is working ok, but I need to be able to remove the border and that doesn't seem to be working. I've searched through this site and can't find anything close apart from this:
模仿文字边框和阴影选项适用于:"(文本) 在内嵌形状上使用 vba
代码如下:
Sub TestAddBorders()
Sub TestAddBorders()
Dim rngShape As InlineShape
For Each rngShape In ActiveDocument.InlineShapes
With rngShape.Range.Borders
.OutsideLineStyle = wdLineStyleSingle
.OutsideColorIndex = wdPink
.OutsideLineWidth = wdLineWidth300pt
End With
Next rngShape
结束子
Sub TestRemoveBorders()
Sub TestRemoveBorders()
Dim rngShape As InlineShape
For Each rngShape In ActiveDocument.InlineShapes
With rngShape.Range.Borders
.OutsideLineStyle = wdLineStyleNone
End With
Next rngShape
结束子
我总是留下一张周围有灰色边框的图片(inlineshape).在图片工具">格式"选项卡上使用图片边框 > 无轮廓"将其删除,但我在 VBA 中找不到任何方法.wdLineStyleNone 似乎不起作用,我看不到 color = "none" 或 linewidth = "none" 的选项
I am always left with a picture (inlineshape) that has a greyish border around it. Using "Picture Border > No Outline" on the Picture Tools > Format Tab removes it, but I can' find any way to do it in VBA. The wdLineStyleNone just doesn't seem to work and I can't see an option for colour = "none", or linewidth = "none"
谢谢.
推荐答案
来自 MSDN:
要移除对象的所有边框,请将 Enable 属性设置为 False.
To remove all the borders from an object, set the Enable property to False.
http://msdn.microsoft.com/en-us/图书馆/办公室/ff196058.aspx
这将在您应用边框时删除它们:
This will remove the borders as you applied them:
Sub TestRemoveBorders()
Dim rngShape As InlineShape
For Each rngShape In ActiveDocument.InlineShapes
With rngShape.Range.Borders
.Enable = False
End With
Next rngShape
End Sub
上述方法删除边框,但不删除线条.要删除行,请尝试以下操作:
The above method removes borders but not lines. To remove lines, try this:
With rngShape.Line
.Visible = msoFalse
End With
这篇关于如何从内联形状中删除边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!