Word 中几个较有用的宏

Sub 文本粘贴1()
    'ctrl+1
    '用于粘贴纯文本
    Selection.PasteAndFormat (wdFormatPlainText)
 
End Sub

Sub 文本粘贴2()
     'ctrl+2
     '用于粘贴从一般新闻网页中复制下来的文本,会自动去除多余的制表符和双行符。

    Selection.PasteAndFormat (wdFormatPlainText)
 
    With Selection.Find
        .Text = " "
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
     With Selection.Find
         .Text = "^p^p"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
End Sub


Sub 重新排版()

    'strl+3
    '去除图像转文字带来的多余回车符。事先须在正确的回车符后而加入“##”串。

    With Selection.Find
        .Text = "^p"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
    With Selection.Find
        .Text = "##"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
    
End Sub

图像裁切和大小调整


Sub 宏1()
'
' 宏1 宏
'
'
Dim n
On Error Resume Next
'For n = 1 To ActiveDocument.InlineShapes.Count
For n = 1 To 3
 ActiveDocument.InlineShapes(n).PictureFormat.CropTop = 100
 ActiveDocument.InlineShapes(n).PictureFormat.CropBottom = 50
 ActiveDocument.InlineShapes(n).PictureFormat.CropLeft = 75
 ActiveDocument.InlineShapes(n).PictureFormat.CropRight = 75
 ActiveDocument.InlineShapes(n).ScaleHeight = 95
 'ActiveDocument.InlineShapes(n).ScaleWidth = 95
 Next n
 

End Sub

A4扫描为jpg后导入word时将四个页边距均调整为0.43,再执行如下宏

Sub 宏1()

Dim n
On Error Resume Next
For n = 1 To ActiveDocument.InlineShapes.Count
 ActiveDocument.InlineShapes(n).PictureFormat.CropTop = 10
 ActiveDocument.InlineShapes(n).PictureFormat.CropBottom = 10
 ActiveDocument.InlineShapes(n).PictureFormat.CropLeft = 10
 ActiveDocument.InlineShapes(n).PictureFormat.CropRight = 10
 ActiveDocument.InlineShapes(n).ScaleHeight = 100
 ActiveDocument.InlineShapes(n).ScaleWidth = 100
 Next n
End Sub

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值