Autosize text box: how to update in macro?

J

Jonathan Bromley

Please help, experts!

I'm using PPT 97 and trying to write a VB macro to create a custom
layout of text and graphics. To do this I need to know how much space
to allow for each piece of text. The obvious approach (to me!) is
to use the text frame's "auto size" capability. So let's create a
text box:

' Note: arbitrary size - it will be resized later
Set s = some_slide.Shapes.AddShape(msoShapeRectangle, 0, 0, 1,1)
With s.TextFrame
.text = "some string"
.AutoSize = ppAutoSizeShapeToFitText
End With
DoEvents ' I hoped this would update the text frame's size...
w = s.Width ' How big is my text?

This doesn't appear to work reliably. What can I do to get a
complete repaint, correctly updating the text frames' sizes,
whilst the macro is running? I don't mind if it takes a little
while - this macro is run interactively and infrequently.

Alternatively, does anyone know a reliable way to determine the
width and height of a piece of text, given its font?

Many thanks in advance
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
(e-mail address removed)
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 
S

Steve Rindsberg

After changing the text and/or its properties, try testing the .BoundWidth
and/or .BoundHeight properties

Debug.Print s.TextFrame.TextRange.BoundWidth
 
J

Jonathan Bromley

After changing the text and/or its properties, try testing the .BoundWidth
and/or .BoundHeight properties

Perfect! Many thanks.
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
(e-mail address removed)
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 

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