开发者

How to use VBA in Word 2007 to update PictureStyles in one assignment?

开发者 https://www.devze.com 2023-02-01 07:58 出处:网络
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

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 开发者_Go百科it would be.

Thanks, Spencer


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消