2016-05-10 18 views
0

我正在設計一個宏來驗證PowerPoint演示文稿,它檢查幻燈片上的每個文本框/形狀,並輸出字體類型,大小和顏色。我已經開始工作,它會爲每個形狀吐出字體大小,問題是當給定形狀中每行有多個字體大小時。目前,例如,如果第一行是宋體12和下一行是宋體14的輸出,只是需要的第一線,並說也有宋體12在文本框中尋找每行不同的字體

Dim lFindColor As Long 
Dim oSl As Slide 
Dim oSh As Shape 

Dim colorsUsed As String 
Dim fontsUsed As String 

Dim lRow As Long 
Dim lCol As Long 

Dim shpFont As String 
Dim shpSize As String 
Dim shpColour As String 


Set oSl = ActiveWindow.View.Slide 
Dim x As Integer 

    For Each oSh In oSl.Shapes 
    '----Shape Check---------------------------------------------------------- 
     With oSh 
      If .HasTextFrame Then 
       If .TextFrame.HasText Then 
        For x = 1 To .TextFrame.TextRange.Runs.Count 
         shpFont = shpFont & .TextFrame.TextRange.Font.Name & ", " 
         shpSize = shpSize & .TextFrame.TextRange.Font.Size & ", " 
         shpColour = shpColour & .TextFrame.TextRange.Font.Color.RGB & ", " 
        Next 
       End If 
      End If 
     End With 
    Next 

兩行我能做些什麼來搜索每行,並給我一個形狀內的每個單獨的行的字體大小/類型?

回答

2

您正在循環遍歷.Runs(如果完整的TextRange具有相同的一組方法和屬性,則爲子集),但會輸出整個TextRange的樣式屬性。改爲使用.TextFrame.TextRange.Runs(x).Font.Name等。

+0

工作就像一個夢想謝謝你! – SFro

相關問題