Fomat picture in centimeters

B

Brian

Hi All,

I am trying to amend a piece of code to allow the user to search for all
shapes, and resize. I want them to be able to insert the height in
centimeters, in a dialogue box.
Tried a few things, but can't get it to recognise centimeters for the
format. Here is a bit looking only at inlineshapes

Sub PictSize()
Dim HieghtSize As Integer
Dim oIshp As InlineShape
Dim oshp As Shape
HeightSize = InputBox("Enter height ", "Resize Picture", 10)
For Each oIshp In ActiveDocument.InlineShapes
With oIshp
.LockAspectRatio = msoTrue
.Height = HeightSize
End With
Next oIshp
End Sub

Thanks in advance,
 
S

Stefan Blom

VBA code uses points as the unit of measurement, so you'll need to
convert the value entered. For example, like this:

Sub PictSize()
Dim HieghtSize As Integer
Dim oIshp As InlineShape
Dim oshp As Shape
HeightSize = InputBox("Enter height ", "Resize Picture", 10)
For Each oIshp In ActiveDocument.InlineShapes
With oIshp
.LockAspectRatio = msoTrue
'Here's the modified line of code:
.Height = CentimetersToPoints(HeightSize)
End With
Next oIshp
End Sub

--
Stefan Blom
Microsoft Word MVP


in message
news:[email protected]...
 
B

Brian

Stefan,

Thanks for the quick response.
One more question, any idea why the LockAspectRatio isn't working in my code?

Thanks
 
S

Stefan Blom

I seem to recall previous reports that it doesn't work correctly. :-(

You'll have to calculate it yourself (or, rather, have VBA do it).

--
Stefan Blom
Microsoft Word MVP


in message
 

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