Help writing a picture formatting macro

S

sotiris5000

Hello,

I was wondering if you guys could help me.


I am trying to write a macro to format a picture I have pasted into a
word document.

Unfortunately the wrap to text and advanced functions of the format
picture tab are not available when writing a macro.


I have seen someone here had the same problem and the following code
was posted:


With myShape
.WrapFormat.Type = wdWrapTopBottom
.WrapFormat.DistanceTop = InchesToPoints(0.2)
.WrapFormat.DistanceBottom = InchesToPoints(0.2)
.RelativeHorizontalPosition =
wdRelativeHorizontalPositionPage
.Left = wdShapeCenter



The thing is my requirements are different to this and now matter how
I change the code above I can't get it to work.


Can anyone help please?

I need the options

Wrap type = Square

Horizontal Alignment = Other


and in the advanced options


Absolute position 4.23 from the right of the page

Absolute position 0.00 below paragraph.





I know this is quite complicated and a big ask - but if anyone can
help it would be amazing as i have to format pictures according to
this layout about 20 times a day as part of my job and a macro would
totally help me out.



Thanks,


Sotiris
 
H

Helmut Weber

Hi,

make sure, that the picture is a shape beforehand, like:

Selection.InlineShapes(1).ConvertToShape '!
With Selection.ShapeRange
.WrapFormat.Type = wdWrapTopBottom
.WrapFormat.DistanceTop = InchesToPoints(0.2)
.WrapFormat.DistanceBottom = InchesToPoints(0.2)
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.Left = wdShapeCenter
End With

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
S

sotiris5000

Hi,

Thanks for getting back to me.

Yeah I have already done that, the issue is with changing that script
I have for the options below.

Wrap type = Square


Horizontal Alignment = Other


and in the advanced options


Absolute position 4.23 from the right of the page


Absolute position 0.00 below paragraph.


Any help would be super-greatly appreciated.
 
H

Helmut Weber

Hi Sotiris

try:

Sub Test9987()
Dim x As Single ' width of page
Dim w As Single ' width of picture
x = ActiveDocument.PageSetup.PageWidth

With Selection.ShapeRange
w = .Width
.WrapFormat.Type = wdWrapSquare
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
.Left = x - CentimetersToPoints(4) - w
.Top = CentimetersToPoints(0)
' default anyway ?
' top of picture = top of paragraph
End With
End Sub

I think, the dialog is misleading.
Format picture, layout, advanced,
vertical, absolute position, below paragraph
is referring to the top of the paragraph.

HTH




--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top