OLE inline object position

G

Gla Norham

When you insert a microsoft equation in, say, a word document the equation's
vertical center is automatically aligned with the baseline of the text
surrounding it.

I wonder how this behavior is implemented?

When I insert an inline picture in Word, I can vertically position it using
VBA macro as InlineShapes(1).Font.Position(-5) but that brings other nasty
side effects.

Is there a method in the relevant OLE interfaces that I can use (or
implement) to lower-raise inline OLE object in Word?

Regards

Gla
 
C

Cindy M -WordMVP-

Hi Gla,
When I insert an inline picture in Word, I can vertically position it using
VBA macro as InlineShapes(1).Font.Position(-5) but that brings other nasty
side effects.
For example?
Is there a method in the relevant OLE interfaces that I can use (or
implement) to lower-raise inline OLE object in Word?
Not other than the one you've already discovered.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
G

Gla Norham

Thanks for the reply Cindy.

First let me correct the code I included

Sub chpos()
ActiveDocument.InlineShapes(1).Select
Selection.Font.Position = -15
End Sub
---

Side effect is the following; when you bring the cursor just to the right of
the picture, the characters you insert by typing are positioned at -15, not
on the normal baseline. Well, this is somewhat expected because Word
apparently assumes that you implicitly accept the preceding formatting when
you insert at a particular point.

Microsoft Equation somehow manages to avoid this problem. When you insert an
inline equation it is centered with respect to the baseline of the
surrounding text. Yet the Font.Position property is still 0. So I thought,
maybe there is something, some property in OLE framework that you set while
designing your COleDocument object.

Regards,

Gla
 
C

Cindy M -WordMVP-

Hi Gla,
Microsoft Equation somehow manages to avoid this problem. When you insert an
inline equation it is centered with respect to the baseline of the
surrounding text. Yet the Font.Position property is still 0. So I thought,
maybe there is something, some property in OLE framework that you set while
designing your COleDocument object.
Actually, from what I've seen, most OLE objects do NOT center on the baseline
when they're inserted. They usually drop a bit below, but not that much. So I
was a bit surprised to read "When you insert a microsoft equation in, say, a
word document the equation's vertical center is automatically aligned with the
baseline of the text surrounding it." in your original posting. But hey, Word
doesn't always behave the same on every installation...

Now you appear to be saying something different, that it ALIGNS vertically with
the baseline (rather than centering on it, which would mean the middle of the
object aligns with the text), which is what I would expect to see with Equation
and other OLE things. What is it you have that is NOT aligning correctly? What
are you trying to do?
Side effect is the following; when you bring the cursor just to the right of
the picture, the characters you insert by typing are positioned at -15, not
on the normal baseline. Well, this is somewhat expected because Word
apparently assumes that you implicitly accept the preceding formatting when
you insert at a particular point.
Yes. You can press Ctrl+Spacebar to revert back to the paragraph style font
settings, though.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
G

Gla Norham

Hi Cindy,

I have just tried inserting a few OLE objects inline and it seems Equation
Editor is more intelligent than I first thought; it not only changes the
vertical alignment of the object wrt baseline but also does it takes into
account the meaning of the equation inside the object. For example if you
have

b
-----
c
a= -------
d

in an equation the = alignes vertically slightly above the baseline of the
surrounding text, which is what should happen.

I was wondering how this could be done within an OLE server application. My
guess is that Word treats an inline object as a character picked from a
custom font and as part of font char attributes it sets the proper vertical
alignment. I have nothing to support this guess, though. Only what I have
been reading about fonts, OLE and stuff.

So, I am tring to build an OLE server whose inline objects should behave as
equations do; have a custom vertical alignment wrt the surrounding text.

regards

Gla
 
C

Cindy M -WordMVP-

Hi Gla,
So, I am tring to build an OLE server whose inline objects should behave as
equations do; have a custom vertical alignment wrt the surrounding text.
I understand. And since the Equation Editor is licensed from a third-party
(it's a trimmed down version of MathType, from Design Science) it must,
indeed, be possible. Unfortunately, I have no idea how they manage it :-(

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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