スライドにソースコードを貼りつけることがしょっちゅうあるんですが、
キーワードハイライトがやりにくくてしょうがないです。
うまい方法があったら教えてください。
Option Explicit Public Sub CSharpのキーワードの色を変更する() Dim keywordList() As String keywordList = Split("as,if,try,finally,catch,new,null,true,false,string", ",") Dim keywordColor As Long keywordColor = rgb(0, 0, 255) Dim typenameList() As String typenameList = Split("Path,Interior,Font,Console,COMException,XlSaveAsAccessMode,XlFileFormat,Type,Marshal,Application,Workbooks,Workbook,Sheets,Worksheet,Range", ",") Dim typenameColor As Long typenameColor = rgb(0, 128, 128) Dim i As Integer For i = LBound(keywordList) To UBound(keywordList) Call FindAndChangeColor(keywordList(i), keywordColor) Next For i = LBound(typenameList) To UBound(typenameList) Call FindAndChangeColor(typenameList(i), typenameColor) Next End Sub Sub FindAndChangeColor(ByVal keyword As String, ByVal newColor As Long) Dim sld As Slide Dim shp As Shape Dim txtRng As TextRange Dim foundText As TextRange For Each sld In Application.ActivePresentation.Slides For Each shp In sld.Shapes If shp.HasTextFrame Then Set txtRng = shp.TextFrame.TextRange Set foundText = txtRng.Find(FindWhat:=keyword) Do While Not (foundText Is Nothing) With foundText .Font.Color.rgb = newColor Set foundText = _ txtRng.Find(FindWhat:=keyword, _ After:=.Start + .Length - 1) End With Loop End If Next Next End Sub