vsyam


Hi,

Any idea as to how we can get the height of a field in word in vba

Thank you.




Re: height of a field in word

Shasur


Hi Syam

There is not outright property for getting the height of the field. However, you can use the following alternative

Code Snippet

Sub Field_Height()

For Each fld In ActiveDocument.Fields
fld.Select
a = Selection.Paragraphs(1).Range.Start
b = Selection.Paragraphs(1).Range.End
MsgBox b - a
Next fld


End Sub

Cheers

Shasur

http://dotnetdud.blogspot.com







Re: height of a field in word

vsyam

Dear Shasur,

I wanted the height of the field. I dont know how the equation you sent will get that. Range.start and range.end will give the character positions in the field code. Please give your full attention to the problem and I am sure you can help me.

Regards,

Syam.






Re: height of a field in word

Shasur

Hey Shyam

What type of fields do you have. Is it Embedded figure/Equation

Will get back to you with the height one.

If it is about shapes you can use the following http://vbadud.blogspot.com/2007/07/get-height-width-of-shapes-figures-in.html

Regards

Shasur






Re: height of a field in word

Shasur

Try this out Shyam it Works for Shapes

Code Snippet

Sub Field_Height_New()

Dim fld As Field
For Each fld In ActiveDocument.Fields
fld.Select
If Not fld.InlineShape Is Nothing Then
lWidth = fld.InlineShape.Width
lHeight = fld.InlineShape.Height
End If
Next fld


End Sub






Re: height of a field in word

vsyam

Dear Shasur,

Thank you for all the responses. The fields that I am talking about contain mathematical expressions of the sort {EQ \F(2.3)*\R(3,8)}. Yes the code you sent above helps me with any inline shapes. I figured this sometime back. The only place I got stuck is the height of these fields. There seems no straight-forward way to get the height. Probably I will have to resort to some empirical methods if the theoretical ways dont work. :-)

Regards,

Syam.





Re: height of a field in word

Shasur

Hi Shyam

I understand, the equation fields are nemesis for getting attributes.

One crude method would be to convert the field to picture (with some place holders/bookmarks) and then get the height and width of each picture.

Good luck for you to come out of it

Regards

Shasur