VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} CodeColor
Caption = "CodeColor"
ClientHeight = 2460
ClientLeft = 120
ClientTop = 465
ClientWidth = 7740
OleObjectBlob = "CodeColor.frx":0000
StartUpPosition = 1 '所屬視窗中央
End
Attribute VB_Name = "CodeColor"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub SelectionFontColor(colorNum_VBARGB As Long)
With Selection.Font
.Color = colorNum_VBARGB
.Name = system.CodeFontName '"consolas" '"verdana"'"jetbrains mono"
End With
Me.Hide 'Unload Me
End Sub
==========================
Attribute VB_Name = "system"
Option Explicit
Property Get CodeFontName() As String
If strCodeFontName = "" Then
'Application.FontNames property (Word)'https://docs.microsoft.com/zh-tw/office/vba/api/word.application.fontnames?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev11.query%3FappId%3DDev11IDEF1%26l%3Dzh-TW%26k%3Dk(vbawd10.chm158334987)%3Bk(TargetFrameworkMoniker-Office.Version%3Dv15)%26rd%3Dtrue
For Each strCodeFontName In Word.Application.FontNames 'if the num of fonts installed in the OS is too much, it'll be a long time to search
If strCodeFontName = "JetBrains Mono" Then Exit For 'case sensitive for comparing
Next strCodeFontName
End If
If Not strCodeFontName = "JetBrains Mono" Then strCodeFontName = "Consolas" 'case insensitive for setting
CodeFontName = strCodeFontName 'encapsulate the field strCodeFontName
End Property