[VBA]批量替換PPT裡的字型顏色

來源:互聯網
上載者:User

標籤:des   style   class   blog   code   http   

不知道為什麼計組老師的大量課件字型是傷害視力的亮藍色……看久了眼睛疼,想把顏色替換成保護視力一點的灰色,但是找了N久也沒找到在圖形介面上直接操作的方法,於是在MSDN上晃了晃,Google了一下,寫了個VBA小指令碼,只替換選定顏色,這樣可以保留紅色或者其他顏色的高亮,順便把讓人分心的花花背景也幹掉。

 

Sub ReplaceColor()Dim shape As shapeDim slide As slideDim txt As TextRangeOn Error Resume Next‘替換背景顏色為白色ActivePresentation.SlideMaster.Background.Fill.SolidActivePresentation.SlideMaster.Background.Fill.ForeColor.RGB = RGB(255, 255, 255)For Each slide In ActivePresentation.Slides   For Each shape In slide.Shapes      Set txt = shape.TextFrame.TextRange      For Each sentence In txt.Sentences        For Each word In sentence.Words          ‘把藍色的文字替換成灰色          If word.Font.color.RGB = RGB(0, 0, 204) Or word.Font.color.RGB = RGB(0, 0, 122) Then            With word.Font              .color.RGB = RGB(40, 40, 40)            End With          End If        Next      Next   NextNextEnd Sub

 

 

Before

 

After

我承認我只是在逃避複習計組………………用LP1、LP2、LP3這種標記名的組譯工具簡直不想多看一眼好嗎!!!

其實還有一點缺陷,不能替換掉表格裡的字型……不過真的不能再浪費時間跑去查文檔鼓搗了(何況我幾乎不會VB=。=) 明晚就考試,複習複習……

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.