Finding Top & height of text in Powerpoint

A

Abhishek Bagga

Hi! everybody
I am using PPT XP (Office XP)
I am facing a problem in extracting the height and top of text in a textbox
I am using the the property

sTextRange.Runs(iRuns,1).BoundHeight And
sTextRange.Runs(iRuns,1).BoundTop (where iRuns is a incermental integer)

but this does not give me exact top & height rather it gives me the top &
height of the biggest character in the textbox.
e.g if i have the first character of a line with bigger font size to
emphasixe the top & height of all the characters is given as same as that of
the biggest character.
I need to extract it for each character.

Is there any way out wherein i can find the exact top & height of the
individual characters, even if i get the top it will work for me.

Any help & suggestions would be welcomed

I have posted this same question in office.developer.VBA forum as well since
i do not know cross-posting to various forums. Any inconvenience is regretted
 
S

Steve Rindsberg

sTextRange.Runs(iRuns,1).BoundHeight And
sTextRange.Runs(iRuns,1).BoundTop (where iRuns is a incermental integer)

but this does not give me exact top & height rather it gives me the top &
height of the biggest character in the textbox.
e.g if i have the first character of a line with bigger font size to
emphasixe the top & height of all the characters is given as same as that of
the biggest character.
I need to extract it for each character.

Is there any way out wherein i can find the exact top & height of the
individual characters, even if i get the top it will work for me.

I don't think there's any way for PowerPoint to return the information you
want, at least not directly.

You could possibly create your own text box for each character on the fly and
use the same method to get its top relative to the top of the text box, then
use that to work out the offset from the real text box you're testing.
 
A

Abhishek

Thanks Steve I'll Chk this and let u know whether i was successful in
acheiving it or not.
I have read ur reply on the other forum as well thanks again. We will
continue over here.

Regards
Abhishek Bagga

Abhishek SignatureAbhishek Bagga Sikhya Solutions Ltd. www.sikhya.com
(+919815005578
 
A

Abhishek

One more thing Steve
If we have to achieve this we have to use Paste Special to paste the
formatted text from the current textbox to another textbox(new) as you have
described.
I can achieve this manually by inserting a new textbox, copying the
character and choosing paste special with formatted options and the deleting
the textbox.
how do i acheive this programatically
what i am able to do is
int
newShapeID=m_PPTSlide.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrienta
tion.msoTextOrientationHorizontal,0,0,100,100).Id;

or

m_PPTSlide.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTex
tOrientationHorizontal,0,0,100,100).TextFrame.TextRange.Text="A";

now how do i copy the single character cause it only gives the option of '
copyTo' function

secondly how do I use the pasteSpecial feature for a single character

One workaround that i have thought of is to copy the complete textbox and
paste it as new and then delete all the characters except the one working
upon.

This should work fine but then how do i delete the currently created new
textbox.

I am able to get its ID but not its Index property which is required to
refer shapes.

Kindly suggest me the best way possible to achieve this

Thanks

Abhishek



Abhishek SignatureAbhishek Bagga Sikhya Solutions Ltd. www.sikhya.com
(+919815005578
 
A

Abhishek

Can I get the Base of the text in a textbox e.g the bottomline where the
character is written.
It is aprox 20% from the bottom but even in that case the letters g,j,p,q,y
start from even lower so thats again a problem.
Can u give a workaround I simply need to redraw the text on a blnk canvas.
Either I get the correct top and height of the eac character or the
bottom/baseline. The rest I'll achieve.

Abhishek
 
S

Steve Rindsberg

If we have to achieve this we have to use Paste Special to paste the
formatted text from the current textbox to another textbox(new) as you have
described.

I'd just copy the textbox instead. It'll retain all properties of the original
that way. Then delete all the characters but the one you're after.

Depending on how much text you need to process, it might make sense to store
the results (in an array perhaps). Before processing each character, check the
"store" to see if you've already got results for it.

Suppose you've got a reference to the current shape you're testing in oSh
You'd do something like:

Dim oTempShape as Shape

Set oTempShape = oSh.Copy
With oTempShape
' do whatever you need to here
End With
oTempShape.Delete
 
S

Steve Rindsberg

Can I get the Base of the text in a textbox e.g the bottomline where the
character is written.
It is aprox 20% from the bottom but even in that case the letters g,j,p,q,y
start from even lower so thats again a problem.
Can u give a workaround I simply need to redraw the text on a blnk canvas.
Either I get the correct top and height of the eac character or the
bottom/baseline. The rest I'll achieve.

I think you'd need to test with a sample letter that you KNOW has no
descenders, then hang onto that info while you process the rest of the
characters.
 
S

Steve Rindsberg

Steve I am sending you the sample PPT file.
If u could help me i'l thankful to u.
I tried the method told by u but that does not help

The email address I post under is a bogus one.

Let's keep it here in the newsgroup where everyone can learn.
Abhishek SignatureAbhishek Bagga Sikhya Solutions Ltd. www.sikhya.com
(+919815005578
Steve Rindsberg said:
I don't think there's any way for PowerPoint to return the information you
want, at least not directly.

You could possibly create your own text box for each character on the fly and
use the same method to get its top relative to the top of the text box, then
use that to work out the offset from the real text box you're testing.




--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================


[Message contains attachment(s). Extract test1.ppt?]
 

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