Skip to content

Instantly share code, notes, and snippets.

@bitdust
Created January 14, 2018 06:54
Show Gist options
  • Save bitdust/12e3e251f014897fbb9bf3ab4fc7fd8f to your computer and use it in GitHub Desktop.
Save bitdust/12e3e251f014897fbb9bf3ab4fc7fd8f to your computer and use it in GitHub Desktop.
word宏,删除选中文字中的换行及空格,用于调整从PDF文件中复制出的文字格式
Sub 删除换行及空格()
'
' 删除换行及空格 宏
' 用于调整从PDF文件中复制出的文字格式
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment