2014-02-12 57 views
0

我剛剛開始學習VBA for PowerPoint(大約30分鐘前)的編程。誰能幫我?:以下VBA宏用於更改註釋顏色

我想宏通過所有幻燈片註釋循環和更改文本爲白色

(我知道有非宏替代這一點,但第三第三方軟件(Articulate)需要通過宏...長故事來完成)。

這是我到目前爲止有:

Sub changenotestowhite() 
    Dim osld As Slide 
    Dim oshp As Shape 
    Dim strNotes As String 
    For Each osld In ActivePresentation.Slides 
     For Each oshp In osld.NotesPage.Shapes 
     oshp.TextFrame.TextRange.Font.Color = vbWhite 
     Next oshp 
    Next osld 
End Sub 

我收到錯誤消息「運行時錯誤:指定的值超出範圍」

謝謝!

回答

0

歡迎MS/VB著名的紅鯡魚(又名錯誤消息)的世界。

問題是這樣的:有些形狀沒有文本框架(保存文本的形狀的屬性),即使形狀具有文本框架,也可能沒有任何文本。試圖更改不存在的文本,或者文本框中不存在的文本會導致錯誤。

使用此相反,測試對於文本框,如果存在,文本框是否有之前以任何方式改變文本的文本:

Sub changenotestowhite() 
    Dim osld As Slide 
    Dim oshp As Shape 
    Dim strNotes As String 
    For Each osld In ActivePresentation.Slides 
     For Each oshp In osld.NotesPage.Shapes 
     If oshp.HasTextFrame Then 
     If oshp.TextFrame.HasText Then 
     oshp.TextFrame.TextRange.Font.Color = vbWhite 
     End If 
     End If 
     Next oshp 
    Next osld 
End Sub 
+0

史蒂夫。 你是一個怪胎的傳奇人物。我建議你訪問你的社交媒體渠道並宣佈這一事實。人們需要知道。 現在我擁有這樣的知識,我將繼續並改變文本的大小和音符的對齊方式。 非常感謝你;我永遠感激, 喬 –

+0

喬 - ;-)一個溫和的傳說,也許。很高興幫助。 –

+0

Font.Color屬性是隻讀的。您需要使用Font.Color.RGB = RGB(255,255,255),而不是每個MSDN https://msdn.microsoft.com/en-us/library/office/ff744240.aspx?f=255&MSPPError=- 2147217396。 – OfficeAddinDev

相關問題