【问题标题】:How to create image border?如何创建图像边框?
【发布时间】:2021-11-14 04:50:08
【问题描述】:

在 Word for Mac 中,我正在尝试执行以下操作: http://www.vbaexpress.com/forum/showthread.php?48376-VBA-Macro-To-Insert-Border-For-All-Images

给定一个没有边框的内联图像,我选择它,然后在即时窗口中执行:

Selection.InlineShapes(1).Borders(wdBorderLeft).LineStyle = wdLineStyleSingle ' value 1

Word for Mac 接受这一点,但如果我随后检查

Selection.InlineShapes(1).Borders(wdBorderLeft).LineStyle

我看到该值仍然为零。图像上也没有边界线。这意味着当我尝试设置任何其他左边框属性时,它会失败,并出现错误 5843。

如果我使用形状属性对话框设置边框,LineStyle 会正确显示为 1。

我认为 Word for Windows 中没有这个问题。

【问题讨论】:

  • 即使 Selection.InlineShapes(1).Borders.Enable = True 也不起作用...

标签: vba macos image ms-word border


【解决方案1】:

在尝试了 Applescript 之后,天知道还有什么,我终于发现 Microsoft 文档和 VBAExpress 配方完全是错误的(至少对于 Word 2016)。

使用 Line 对象代替 Borders 对象:

With Selection.InlineShapes(1)
    .Line.Visible = lineVisible
    If lineVisible <> False Then
        .Line.Style = lineStyle
        .Line.Weight = lineWeight
        .Line.ForeColor = lineColor
    End If
End With

相关代码和上下文见https://github.com/charlesweir/WordImagesAndTables/blob/master/FiguresAndTables.bas。

【讨论】:

    猜你喜欢
    • 2011-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-13
    • 1970-01-01
    • 2019-10-06
    • 1970-01-01
    相关资源
    最近更新 更多