Created
September 11, 2015 07:10
-
-
Save kencoba/8c4d5a2784f2dab01245 to your computer and use it in GitHub Desktop.
keyword coloring for word
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub キーワードカラー() | |
Dim keywordList() As String | |
keywordList = Split("abstract,continue,for,new,switch,assert,default,goto," & _ | |
"package,synchronized,boolean,do,if,private,this,break,double,implements,protected," & _ | |
"throw,byte,else,import,public,throws,case,enum,instanceof,return,transient," & _ | |
"catch,extends,int,short,try,char,final,interface,static,void," & _ | |
"class,finally,long,strictfp,volatile,const,float,native,super,while", ",") | |
Dim keywordColor As Long | |
keywordColor = RGB(128, 0, 64) | |
Application.ScreenUpdating = False | |
Dim i As Integer | |
For i = LBound(keywordList) To UBound(keywordList) | |
Call FindAndChangeColor(keywordList(i), keywordColor) | |
Next | |
Application.ScreenUpdating = True | |
End Sub | |
Private Sub FindAndChangeColor(ByVal keyword As String, ByVal newColor As Long) | |
Dim wdWrd | |
For Each wdWrd In ActiveDocument.Words | |
With wdWrd | |
Select Case Trim(wdWrd) | |
Case Is = keyword | |
.Font.Color = newColor | |
Case Else | |
End Select | |
End With | |
Next wdWrd | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment