【VBA自用常用模板2】WORD/WPS办公宏实现切换页面背景/切换页面视图

对接上一自用模板,为功能有切换页面护眼绿()、切换页面视图、模拟快捷键点击,可以为其添加快捷键

Sub 切换页面护眼绿()

If (ActiveDocument.Background.Fill.ForeColor.ObjectThemeColor = _
        wdThemeColorAccent6) Then
   ActiveDocument.Background.Fill.ForeColor.ObjectThemeColor = _
        wdThemeColorBackground1
    ActiveDocument.Background.Fill.ForeColor.TintAndShade = 0#
    ActiveDocument.Background.Fill.Visible = msoTrue
    ActiveDocument.Background.Fill.Solid
    
Else
      ActiveDocument.Background.Fill.ForeColor.ObjectThemeColor = _
        wdThemeColorAccent6
    ActiveDocument.Background.Fill.ForeColor.TintAndShade = 0.8
    ActiveDocument.Background.Fill.Visible = msoTrue
    ActiveDocument.Background.Fill.Solid
End If
    
End Sub

折腾了好久,试了好多好多遍才找到适合WPS的方案
那个RGB颜色不是真的RGB,得去word哪里边录制宏边调字体背景颜色才弄找得到自己想要的颜色.
但是呢,得手动变化一次背景太麻烦了


Sub 护眼绿切换()
'
' Macro1 Macro
' 宏由 lalal 录制,时间: 2023/02/19


If (ActiveDocument.Background.Fill.ForeColor.RGB = _
        wdColorWhite) Then
    ActiveDocument.Background.Fill.ForeColor.RGB = 14149338
Else
    ActiveDocument.Background.Fill.ForeColor.RGB = wdColorWhite
End If

End Sub

经常要并排查看word,而放大后有经常是显示不全,web视图就很好解决问题,设置快捷键即可一键切换

Sub web视图切换()
'
    If (ActiveWindow.ActivePane.View.Type = wdPrintView) Then
        ActiveWindow.ActivePane.View.Type = wdWebView
    Else
        ActiveWindow.ActivePane.View.Type = wdPrintView
    End If

End Sub


模拟点击,因为个人习惯设置F4是阅读文字


Sub 按键F4()
//模拟键盘点击F4
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.SendKeys "{F4}"
End Sub

;但WPS只能触发一次,在wps用vba真的太难受了
Sub 组合键打开段落设置()
'
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.SendKeys "%{h}{k}{down 6}{enter}"

End Sub

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值