如何在 Word 2007 中使用 VBA 在一项作业中更新 PictureStyles?

发布于 2024-10-09 07:32:16 字数 483 浏览 0 评论 0原文

我正在尝试帮助同事处理一些 Word 2007 图片格式设置。我希望能够通过将图片指定为您可以从功能区的“图片格式”选项卡中选择的命名样式之一来更新边框样式、阴影等。我尝试使用的样式称为“简单框架,黑色”。不幸的是,我在对象模型参考中没有找到任何有关将这些样式用于 InlineShapes 的文档。

我尝试录制宏,既使用鼠标执行步骤,又仅使用键盘执行我想要的操作,但没有任何图片样式分配步骤显示在生成的 vba 模块中。

我在egghead上发现了一个类似的问题 这里

由此看来,这个功能可能没有在对象模型中公开。我想知道是否有人找到了一种方法来做到这一点,如果没有,解决这个问题的最佳方法是什么。

谢谢, 斯宾塞

I am trying to help a co-worker with some Word 2007 picture formatting. I would like to be able to update the Border style, drop-shadow, etc. by assigning the pictures one of the named styles that you can select from the Picture Formatting tab in the ribbon. The style I am trying to use is called 'Simple Frame, Black'. Unfortunately, I haven't found any documentation in the Object Model Reference about using these styles for InlineShapes.

I tried recording a macro, both by using the mouse to go through the steps, and only using the keyboard to do what I want, but none of the picture style assignment steps show up in the resulting vba module.

I found a question that is similar on egghead here

From this, it sounds as though maybe this functionality isn't exposed in the Object model. I'm wondering if anyone has found a way to do this, and if not, what the best way to get around it would be.

Thanks,
Spencer

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

安静 2024-10-16 07:32:16

据我所知,没有办法直接从 VBA 设置命名图片样式。这有点耗时,但我的建议是将两张图片插入到一个 Word 文档中,对其中一张图片应用格式,然后在 VBE Watch 窗口中检查这两个对象。

根据我使用Word 2010的经验,需要注意的事情是:BordersFillGlowPictureFormat >, 反射, 阴影, & SoftEdge

在 Word 2010 中,要更改不带格式的图片,使其具有与“简单框架,黑色”样式相同的格式,请应用以下更改:

With ThisDocument.InlineShapes(1)
   .Borders.OutsideLineStyle = wdLineStyleSingle
   .Borders.OutsideLineWidth = wdLineWidth300pt
   With .Shadow
      .Blur = 4
      .OffsetX = 2.12132
      .OffsetY = 2.12132
      .Style = msoShadowStyleOuterShadow
      .Transparency = 0.57
      .Visible = msoTrue
   End With
End With

阴影模糊和偏移是您无法真正看到的细微更改。

As far as I can tell there isn't a way to directly set the named picture styles from VBA. It is a little time consuming but my suggestion would be to insert two pictures into a word document, apply the formatting to one of them, then examine both objects in the VBE Watch window.

Based on my experience with Word 2010, the things to pay attention to are: Borders, Fill, Glow, PictureFormat, Reflection, Shadow, & SoftEdge.

In Word 2010 to change a picture without formatting to have the same formatting as the 'Simple Frame, Black' style apply the following changes:

With ThisDocument.InlineShapes(1)
   .Borders.OutsideLineStyle = wdLineStyleSingle
   .Borders.OutsideLineWidth = wdLineWidth300pt
   With .Shadow
      .Blur = 4
      .OffsetX = 2.12132
      .OffsetY = 2.12132
      .Style = msoShadowStyleOuterShadow
      .Transparency = 0.57
      .Visible = msoTrue
   End With
End With

The Shadow Blur and Offsets are minor changes you can't really see.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文