zoukankan      html  css  js  c++  java
  • Delphi 运行Word VBA 宏 删除软回车

    Sub 整理网页()
    '整理网页:删除软回车、删除空白段、使段落文字两端对齐
    Selection.WholeStory
       
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
            .Text = "?^l"
            .Replacement.Text = "^&^p"
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchByte = False
            .MatchAllWordForms = False
            .MatchSoundsLike = False
            .MatchWildcards = True
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
       
        With Selection.Find
            .Text = "^1^l"
            .Replacement.Text = "^&^p"
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
       
        With Selection.Find
            .Text = "^l"
            .Replacement.Text = ""
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
       
        With Selection.Find
            .Text = "^p^s"
            .Replacement.Text = "^p"
            .MatchWildcards = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
       
        With Selection.Find
            .Text = "^p^p"
            .Replacement.Text = "^p"
            .MatchWildcards = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
       
        With Selection.Find
            .Text = "^p^p^p"
            .Replacement.Text = "^p"
            .MatchWildcards = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
       
        With Selection.Find
            .Text = "^p^p^p"
            .Replacement.Text = "^p"
            .MatchWildcards = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
       
        With Selection.Find
            .Text = "^p^p"
            .Replacement.Text = "^p"
            .MatchWildcards = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
       
        With Selection.Find
            .Text = "^p^p"
            .Replacement.Text = "^p"
            .MatchWildcards = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
       
        With Selection.Find
            .Text = "^p^p^p"
            .Replacement.Text = "^p"
            .MatchWildcards = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
       
        With Selection.Find
            .Text = "^p^p"
            .Replacement.Text = "^p"
            .MatchWildcards = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
       
        With Selection.Find
            .Text = "^p^p"
            .Replacement.Text = "^p"
            .MatchWildcards = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
       
        With Selection.Find
            .Text = "^p^p"
            .Replacement.Text = "^p"
            .MatchWildcards = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
        Selection.Paragraphs.Alignment = wdAlignParagraphJustify
    End Sub

    Delphi可以通过ole word的方式来运行宏:

    WordDoc := WordApp.Documents.open(fileName:=fn, Revert:=true, Visible := True);
    wordapp.Run( MacroName:='整理网页');

    非常蹊跷的是,如果Visible := False,则word宏不能运行!

  • 相关阅读:
    Spark笔记:RDD基本操作(下)
    Spark笔记:RDD基本操作(上)
    使用mapreduce计算环比的实例
    Hbase学习笔记01
    周爱民:真正的架构师是没有title的(图灵访谈)
    google map 路线服务
    Google Maps V3 之 路线服务
    CSS3支持box-flex弹性布局
    php curl用法
    .frm,.myd,myi转换为.sql导入数据库
  • 原文地址:https://www.cnblogs.com/wxb-km/p/5212101.html
Copyright © 2011-2022 走看看