【VBA自用常用模板1】WORD/WPS办公宏/常用宏/阅读专用VBA

用word阅读论文做笔记时,一些常用的重复操作,网上也找不到相关的教程,自己琢磨试错了好多次才推敲出来;宏也也有用JS写的,但是那个由于本人太菜琢磨不出来哈哈哈哈哈。
然后,配合自定义快捷键Alt+1、+2、+3…真的巨方便,实测WPS可用,OFFICE尚不清楚。

Sub 高光25灰色()
    Selection.Range.HighlightColorIndex = wdGray25
End Sub

Sub 加粗变蓝()
    With Selection.Font
        .Bold = -1
        .BoldBi = -1
        .ColorIndex = wdBlue
    End With
End Sub

Sub 加粗变红()
    With Selection.Font
        .Bold = -1
        .BoldBi = -1
        .ColorIndex = wdRed
    End With
End Sub

Sub 高光黄色()
   Selection.Range.HighlightColorIndex = wdYellow
End Sub

Sub 绿色底纹()
'两个需要搭配使用
    Selection.ParagraphFormat.Shading.Texture = wdTextureSolid
    Selection.ParagraphFormat.Shading.ForegroundPatternColor = 14149338
End Sub
Sub 标题1()
    Selection.Style = "标题 1"
End Sub

Sub 标题2()
    Selection.Style = "标题 2"
End Sub

Sub 标题3()
    Selection.Style = "标题 3"
End Sub

Sub 有序列表()
    Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries(wdNumberGallery).ListTemplates(1), ContinuePreviousList:=wdContinueList, ApplyTo:=wdListApplyToSelection, DefaultListBehavior:=262144
End Sub

Sub 无序列表()
    Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries(wdBulletGallery).ListTemplates(1), ContinuePreviousList:=wdContinueList, ApplyTo:=wdListApplyToSelection, DefaultListBehavior:=262144
End Sub


Sub 去底纹()
'VB是没有透明色的,将图案模式设为NONE,再填充色也就是背景色设为自动

    Selection.ParagraphFormat.Shading.Texture = wdTextureNone
    Selection.ParagraphFormat.Shading.BackgroundPatternColor = wdColorAutomatic
   
End Sub

Sub 不粗不红不高光()
    With Selection.Font
        .Bold = 0
        .BoldBi = 0
        .ColorIndex = wdBlack
        .Italic = 0
    End With
     Selection.Range.HighlightColorIndex = wdWhite
End Sub

Sub 放大()

   ActiveWindow.ActivePane.View.Zoom.Percentage = ActiveWindow.ActivePane.View.Zoom.Percentage + 10
          
End Sub

Sub 缩小()

   ActiveWindow.ActivePane.View.Zoom.Percentage = ActiveWindow.ActivePane.View.Zoom.Percentage - 10
    
End Sub

Sub 比例固定()

    ActiveWindow.ActivePane.View.Zoom.Percentage = 150

End Sub

Sub 无格式粘贴()

    Selection.PasteAndFormat (wdFormatPlainText)
    
End Sub



学习感受

vb就类似ahk一样的脚本执行程序,但毕竟是通用的,而且还是最大限度地适配word的操作,无论是录制宏操作,还是快捷键触发,都没有word好整

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值