View Full Version : Solved: Long text spread over multiple shapes/slides
Yobby
01-31-2013, 05:30 AM
Hi,
I have code that downloads a text and places it in a textbox. This textbox is too small to contain the whole text, so I want the overflowing part to be moved to a textbox on the next slide.
I can check wether it's overflowing with the difference between the properties Height and boundHeight of the shape.
But how do I determine a what word to split the text?
John Wilson
01-31-2013, 09:40 AM
You could compare the bound top and height of each line with the top and height of the shape.
Set otxR = oshp.TextFrame.TextRange
For lineCNT = 1 To otxR.Lines.Count
If otxR.Lines(lineCNT).BoundHeight + otxR.Lines(lineCNT).BoundTop > oshp.Top + oshp.Height Then
MsgBox "Line " & lineCNT & " overflows"
Exit For
End If
Yobby
02-01-2013, 06:32 AM
Thanks, I had just noticed .Words has a BoundHeight also, but .Lines is indeed more efficient.
I now have it like below (slightly edited for clarity):
It just adds as many slides as necessary.
sub pasteText(strText as String)
Dim shVak as Shape
Dim i as Integer, intOverflowLine as Integer
Dim var as Variant
Do
Call subroutineThatAddsSlideAndSelectsIt()
Set shVak = ActiveWindow.View.Slide.Shapes(2)
shVak.TextFrame.TextRange.Text = strText
intOverflowLine = 0
With shVak.TextFrame.TextRange
If .BoundHeight > shVak.Height Then
For i = 1 To .Lines.Count
Set var = .Lines(i)
If var.BoundTop + var.BoundHeight > shVak.Top + shVak.Height Then
intOverflowLine = i
Exit For
End If
Next i
End If
If intOverflowLine = 0 Then Exit Do
strText = .Lines(intOverflowLine, .Lines.Count - intOverflowLine + 1).Text
.Text = .Lines(1, intOverflowLine - 1)
End With
Loop
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.