Sub finishing Web page ()
' Organize Web pages: Delete Soft returns, delete blank segments, align text at the end of the paragraph
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 can run macros in the way OLE Word:
WordDoc: = WordApp.Documents.open (FILENAME:=FN, revert:=true, Visible: = True);
WordApp. Run (macroname:= ' collate Web page ');
It is very strange that if visible: = False, Word macro cannot run!
Delphi Run Word VBA macro remove soft return