Delphi Run Word VBA macro remove soft return

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.