VBA inserts text into a Word document and sets the appropriate text properties

Source: Internet
Author: User

The following VBA code functionality, step one, adds text dzwebs text to the top of Word's current document. Then, set the first paragraph to center, and then add a half inch spacing after the paragraph. The Dzwebs format is set to 36 points, the Arial font.

Dim Rngformat as Range

Set Rngformat = ActiveDocument.Range (start:=0, end:=0)

With Rngformat

. InsertAfter text:= "Dzwebs"

. InsertParagraphAfter

With. Font

. Name = "Official script"

. Size = 36

. Bold = True

End With

End With

With Activedocument.paragraphs (1)

. Alignment = wdAlignParagraphCenter

. SpaceAfter = InchesToPoints (0.5)

End With

Part of the code explains:

Dim Rngformat as Range definition variable

Set Rngformat = ActiveDocument.Range (start:=0, end:=0) sets the position of the Rngformat variable, located at the top of the document

With Rngformat

Inside the code function is to set font size and other properties

End With

With Activedocument.paragraphs (1)

. Alignment = wdAlignParagraphCenter

. SpaceAfter = InchesToPoints (0.5)

End With

The code function is to add a segment after a distance of 0.5 inches

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.