-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFormatSlides.bas
More file actions
69 lines (57 loc) · 2.04 KB
/
Copy pathFormatSlides.bas
File metadata and controls
69 lines (57 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Attribute VB_Name = "FormatSlides"
Public Type ParagraphInfo
FontSize As Integer
FontName As String
FontColor As Long
TextBoxTopDistance As Integer
TextOutlineWeight As Single
TextOutlineColor As Long
End Type
' ========================================================
' Apply a consistent format to the text in all slides
Sub FormatTextInSlides(activePres As Presentation)
Dim oSld As Slide
Dim oShp As Shape
Dim slideWidth As Single
Dim slideHeight As Single
For Each oSld In activePres.Slides
For Each oShp In oSld.Shapes
If oShp.HasTextFrame And oShp.TextFrame.HasText Then
Call FormatText(oShp)
End If
Next oShp
Next oSld
End Sub 'FormatTextInSlides
' ========================================================
' Format text according to requirements
Sub FormatText(oShp As Object)
Dim oTxtRng As TextRange
Dim FontSize As Single
Dim shapeText As String
Dim shapeTextFormatted As String
Dim trimLine As String
Dim shapeTextLines() As String
Dim lineLength As Integer
Dim lineSizePixels As Integer
Dim lineCrossHalfWidth As Boolean
Set oTxtRng = oShp.TextFrame.TextRange
FontSize = oTxtRng.font.Size
shapeText = oTxtRng.text
shapeTextLines = Split(shapeText, vbCr)
formattedTextLength = 0
For Each oLine In shapeTextLines
trimLine = Trim(oLine)
lineLength = Len(trimLine)
If lineLength > 0 Then
'TODO: calculate visible line size (width, height).
'Use it to avoid text in the vertical or horizontal half of the Slide (for 4 TV split display)
'lineCrossHalfWidth = (lineLength * fontSize > g_SlideWidth / 2)
'lineSizePixels = GetLabelPixel(trimLine, oTxtFont.SIZE, oTxtFont.Name)
'Debug.Print trimLine & " : " & lineLength & " : " & lineSizePixels
shapeTextFormatted = shapeTextFormatted & trimLine & vbCr
End If
Next
'remove last vbCr
shapeTextFormatted = Left(shapeTextFormatted, Len(shapeTextFormatted) - 1)
oTxtRng.text = Trim(shapeTextFormatted)
End Sub ' FormatText