[Visual Basic] 纯文本查看 复制代码 Sub 夜间模式() 'By jiohui 2021/5/27
Application.ScreenUpdating = False
Dim currentPageColor '页面当前颜色
Dim setPageColor '页面准备设置的颜色
'===============如果页面不是黑色,就设置为黑色,否则设置为白色==================
With ActiveDocument
.Background.Fill.Visible = msoTrue
.Background.Fill.Solid
.ActiveWindow.View.DisplayBackgrounds = True
End With
currentPageColor = ActiveDocument.Background.Fill.ForeColor.RGB
If currentPageColor <> wdColorWhite Then
setPageColor = RGB(255, 255, 255)
Else
setPageColor = RGB(199, 237, 204)
End If
ActiveDocument.Background.Fill.ForeColor.RGB = setPageColor
'===============如果页面不是黑色,就设置为黑色,否则设置为白色==================
'===============设置全文字体颜色为自动后,把光标置于开头========================
With Selection
.WholeStory
.Font.ColorIndex = wdAuto
.HomeKey unit:=wdStory
End With
'===============设置全文字体颜色为自动后,把光标置于开头========================
Application.ScreenUpdating = True
End Sub
我稍稍修改了一下,在白色和护眼绿之间切换,效果更好,欢迎体验 |