Re: programmatically insert lots of text into a power point presentation.

From: Steve Rindsberg (abuse_at_localhost.com)
Date: 06/26/04


Date: Fri, 25 Jun 2004 20:28:19 EDT


> I suppose I can figure out how many physical lines of text will fit on
> one slide for a given font just by opening up PP and typing in lines.
> That's easy enough.
>
> But one input phrase doesn't == one line of text, because it might
> word wrap. I could count the number of characters that fit on one
> physical line. Then I could assume a phrase will wrap at the last
> whitespace character <= the max number of chars per line.
>
> But I'm hoping there is some way for pp to do this for me, or at least
> just tell me how many lines are in a text box.
>

This should do you. Knowing the font height and line spacing, you should be in good shape:

Function LineCount(oSh As Shape) As Long

    ' return zero if no text, -1 if error
    LineCount = 0
    On Error GoTo ErrorHandler
    With oSh
        If .HasTextFrame Then
            If .TextFrame.HasText Then
                LineCount = .TextFrame.TextRange.Lines.Count
            End If
        End If
    End With
    
NormalExit:
    Exit Function
ErrorHandler:
    LineCount = -1
    Resume NormalExit
    
End Function

Sub TestLineCount()
    ' Use currently selected shape
    Debug.Print LineCount(ActiveWindow.Selection.ShapeRange(1))

End Sub

> > Are you using this in a presentation? or are you using this to publish
> It is a requirement of an existing application. I'm just the grunt
> coder who has to do it :)
>
> > Post back if you still need the macro to break the over-sized textboxes onto
> > multiple slides based on the number of lines in the textbox.
> That macro would be great.
>
> Thanks
>

--
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
Featured Presenter, PowerPoint Live 2004
October 10-13, San Diego, CA    www.PowerPointLive.com
================================================


Relevant Pages

  • Re: master reapplied -- and yet not
    ... Michael Koerner [MS PPT MVP] ... have now also tried using a larger font size on my master. ... This is how PPT works -- the font sizes are smaller on those ... I have only one Master Slide showing when I View/Master/Slide Master. ...
    (microsoft.public.powerpoint)
  • RE: Text size changes when copy-pasting
    ... Select "keep source formatting," and it should set things right. ... Echo [MS PPT MVP] ... > when we paste it into a new slide it keeps changing the ... > font size. ...
    (microsoft.public.powerpoint)
  • Re: How to Get Text X, Y position?
    ... created my own example slide. ... TextRanges(Font and Font size is different). ... Steve Rindsberg, PPT MVP ... float boundLeft = eachTextRange.get_BoundLeft; ...
    (microsoft.public.powerpoint)
  • Re: How to Get Text X, Y position?
    ... I am writing an application which will export power point slide ... Pixels where? ... TextRanges(Font and Font size is different). ... Steve Rindsberg, PPT MVP ...
    (microsoft.public.powerpoint)
  • Re: Linking landscape and portrait presentations
    ... portrait slide fit a landscape slide, keeping the image at the size I need, ... the whole thing won't fit on the slide. ... Or you put the same vertical information on a horizontal slide and play it back as a ... Steve Rindsberg, PPT MVP ...
    (microsoft.public.powerpoint)