Add a border to a page
-
Go to Design > Page Borders.
-
Make selections for how you want the border to look.
-
To adjust the distance between the border and the edge of the page, select Options. Make your changes and select OK.
-
Select OK.
If the page you want to add a border to is in the middle of your document, you must first add section breaks.
-
Go to Design > Page Borders.
-
In the Borders and Shading box, design your border:
-
Under Setting on the left, choose the border style you want.
If you want to remove a border, select None.
-
Under Style, select the line style you want.
-
Select the arrow under Color and choose a border color.
-
Select the arrow under Width and choose the width you want.
Tip: If you want a clip-art border instead, select the arrow under Art and choose a border graphic.
-
-
Next, select the arrow to the right of Apply to and choose This section — First page only.
This setting also works if you’re adding the border to the first page in your document.
-
The Preview box confirms your border styles. To remove the border from one side, select that line in the Preview box.
Tip: To change where the border appears on the page, select Options and adjust the margin settings.
When finished, Select OK.
Word for the web does not let you edit, delete, or add new borders to text.
If you’ve added borders around text in a document you created with the Word desktop app, Word for the web will preserve them.
A potential workaround is to insert a table that contains only one cell, then paste or type your text into that cell.
Need more help?
Download Article
Learn how to insert a lined or art border in Microsoft Word documents on desktop
Download Article
- Adding a Page Border (Windows)
- Adding a Page Border (Mac)
- Adding a Text Border
- Q&A
|
|
|
Do you want to make an outside border in your Microsoft Word documents? You can easily add a solid or dotted border to an entire page or selected content. You can also use Microsoft Word’s included designs to create an artistic border for themed event flyers. This wikiHow will show you how to create a border around text, images, or pages in Microsoft Word using your Windows or Mac computer.
Things You Should Know
- To add a page border, click «Design» → «Page Borders». Select a border setting, style, and page application. Click «OK».
- To add a border around text or images, select the content. Click the «Home» tab and click the arrow next to the border icon. Click «Borders and Shading…»
- Select a border setting, style, and page application. Click «OK».
-
1
Open a project in Microsoft Word. This looks like a W on top of a blue square. Microsoft Word is available to install for Windows.[1]
- You must have a subscription to use Office 365.
- Use this method to add a lined border around a Microsoft Word document. This is different from changing the margins.
-
2
Click Design. This will be in the top toolbar, between Draw and Layout.
Advertisement
-
3
Click Page Borders. You can find this at the left side of the Design section, next to Page Color. It will have an icon of a page with a yellow border.
- A new window will open.
-
4
Click Page Border. This is the middle tab on the Borders and Shading window. You may already be on this tab.
-
5
Select a border setting. In the left-most column, click the border option that you want to use. Select from: None, Box, Shadow, 3-D, and Custom.
- If you want a simple border to go all the way around your page, select Box.
- To add a border with fun images, click the Art drop-down menu and select from Word’s art gallery. This border can be used for themed flyers for holidays and events.
-
6
Select a border style. In the «Style» column, scroll down until you find the border style you want to use, then click the style. Select from the various solid and dotted line styles.
- If needed, you can also change the border’s color and width from the Color and Width drop-down menus, respectively.
-
7
Select pages to use. If you created a new section earlier in this method, click the «Apply to» drop-down box, then click the section to which you want to apply the border in the resulting drop-down menu.
- To apply the border to the first page of your section, click This section — first page only in the drop-down menu.
-
8
Click OK. It’s at the bottom of the page. This will apply the border to your document’s specified page(s).
Advertisement
-
1
Open a project in Microsoft Word. This looks like a W on top of a blue square. Microsoft Word is available to install for Mac.[2]
- You must have a subscription to use Office 365.
-
2
Click Design. This will be in the top toolbar, between Draw and Layout.
-
3
Click Page Borders. You can find this at the left side of the Design section, next to Page Color. It will have an icon of a page with a yellow border.
- The Borders and Shading window will open, set to the Page Border tab. If it isn’t already on the Page Border tab, click it now.
-
4
Select a border setting. In the left-most column, click the border option that you want to use. Select from: None, Box, Shadow, 3-D, and Custom.
- If you want a simple border to go all the way around your page, select Box.
- To add a border with fun images, click the Art drop-down menu and select from Word’s art gallery. This border can be used for themed flyers for holidays and events.
-
5
Select a border style. In the «Style» column, scroll down until you find the border style you want to use, then click the style. Select from the various solid and dotted line styles.
- If needed, you can also change the border’s color and width from the Color and Width drop-down menus, respectively.
-
6
Select pages to use. If you created a new section earlier in this method, click the «Apply to» drop-down box, then click the section to which you want to apply the border in the resulting drop-down menu.
- To apply the border to the first page of your section, click This section — first page only in the drop-down menu.
-
7
Click OK. This is the blue button. This will apply the border to your document’s specified page(s).
Advertisement
-
1
Open a project in Microsoft Word. This looks like a W on top of a blue square.
-
2
Click Home. This is in the top toolbar, between File and Insert.
-
3
Select content. Click and drag your mouse across the text or image(s) around which you want to place a border.
- This method will place a border around an entire selection of images and text together.
- If you want to place a border around a single image, double-click the image. Select a preset style from the Picture Styles section, or click Picture Border to set the color, weight, and design of the border.[3]
-
4
Click
next to the «Borders» button. The Borders button resembles a square divided into four smaller squares; you’ll find it in the «Paragraph» section of options in the toolbar, just right of the paint bucket icon. A drop-down menu will open.
- On a Mac, click the Format menu item at the top of the screen instead.
-
5
Click Borders and Shading…. It’s at the bottom of the drop-down menu. A new window will open.
- On a Mac, you’ll find this option in the middle of the Format drop-down menu.
-
6
Select a border setting. In the left-most column, click the border option that you want to use. Select from: None, Box, Shadow, 3-D, and Custom.
- If you want a simple border to go all the way around your text, select Box.
-
7
Select a border style. In the «Style» column, scroll down until you find the border style you want to use, then click the style. Select from the various solid and dotted line styles.
- If needed, you can also change the border’s color and width from the Color and Width drop-down menus, respectively.
- To add a border with images, click the Art drop-down menu and select a design.
-
8
Select pages to use. If you created a new section earlier in this method, click the «Apply to» drop-down box, then click the section to which you want to apply the border in the resulting drop-down menu.
- To apply the border to the first page of your section, click This section — first page only in the drop-down menu.
-
9
Click OK. This will apply the border to your document’s specified page(s).
- Be sure to save your document when you’re finished.
- You can also use Microsoft Word to create a booklet or another handout flyer.
Advertisement
Add New Question
-
Question
How can I place a border around a picture I’ve inserted into a document?
You do what is shown above, but instead, you click on the picture before you go through the steps.
-
Question
How do I put a border around a table in Microsoft Word?
Go into Format —> Borders and Shading. There you’ll find options for borders you can apply to the table.
-
Question
What three options can I set regarding a picture border?
The three option you can set are: small, medium and large.
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
Thanks for submitting a tip for review!
About This Article
Thanks to all authors for creating a page that has been read 971,313 times.
Is this article up to date?
Contents
- 1 How to Add a Basic Border in Word
- 2 How to Set Alternate Microsoft Word Border Styles and Formatting
- 3 How to Insert a Border in Word for a Single Page
- 4 How to Delete a Page in Word or Add Line Numbers
Page borders are a useful tool. They make your document stand out without looking tacky, while providing a guide should somebody want to staple or hole punch. Today we’re going to show you how to add a border in Word, which has various pre-built design options to spice up your document.
Setting page borders in Word differs by version
The process to create Microsoft Word borders will vary slightly depending on your version. We’re going to assume you have an Office 365 subscription or Office 2019. If you have an older version, look to the layout or page layout tab instead.
In newer versions of Word, there are three in-built page border variants: box, shadow, and 3-D. You can also set custom borders if you wish. The first is the most suitable for an enterprise setting, but the others can be a bit of fun. We’ll show you how to choose between them to suit your preference. Let’s get started:
If you came here for a plain, black border, this section is for you. You can get from blank page to professional-looking border for Word in just a few clicks:
- Open the “Design” tab and click “Page Borders”
- Select “Box” and click “OK”
- Check your new page borders in Word page view
You should see that the border neatly hugs the edge of your text and images without overlapping.
How to Set Alternate Microsoft Word Border Styles and Formatting
If a plain black line is a little too boring for you, you can make use of the Word page border options to customize the shadow, thickness, line style, and more.
- Switch to another border setting and change line style
Instead of choosing a lined “Box” as borders for pages, you can use “None” for the standard invisible border design, or choose “Shadow” or “3-D” for a 3-D effect. “Custom” allows defining your own page border design. Border line style, color and thickness can also be changed. Press “OK” to apply the changes.
- Preview your page borders in your main document window
- Remove an individual border line
If you’d like to remove a specific border line, you can do so by clicking it in the preview on the right-hand side and then pressing “OK”.
- Check your page borders in Word page view
You should see that border you selected is completely gone and the line instead reaches right to the edge of the page.
- Modify the style of a specific Word border line
If you want a single border to be in a different style, you can instead click “Custom”, select a line style, and then click on the border you want to change in the preview window. Press “OK” to apply the changes to your document.
- Check your border line’s new style
7. How to change the colour and width of page borders in Word
If you have a dark document background or black is too boring, you can change your border color and width in the same menu.
Click on the “Color” and “Width” dropdown to do so, then click “OK” to apply the changes. This works for both your border as a whole and a specific border line.
8. View your new border colour and width and adjust as necessary
How to Insert a Border in Word for a Single Page
Quite often it makes sense to only have a border on the first page – for use on a cover page for example. Here’s how you can do that:
- Click the dropdown underneath “Apply to” and choose “This section – First page only”
Selecting this option will apply the border to your first page only. If you want to apply it to a different page, you can click on the page in your document and choose “This section” instead.Alternatively, if you want a border everywhere but the first page, choose “This section – All except first page”.
Press “OK” to apply the changes.
- Make sure the page border in Word applied correctly
How to Delete a Page in Word or Add Line Numbers
Now that you’ve applied your borders, you may notice a blank page at the end of your document with a border around it. You can follow our how to delete a page in Word tutorial to remedy this.
Or, if you want to make your document even more useful, why not learn how to add or remove line numbers? This way, readers can reference any part of your document with ease.
Once in a while, you may find yourself wanting to spice up the layout of your Microsoft Word project, but without going overboard on design elements. This is when Word borders can be a good addition to your page design.
Borders for Word documents can be designed in a variety of styles, from formal and all-business to creative and whimsical.
Need to take your Word project from blah to breathtaking? Take a few minutes to add a Word page border. With the presets and customizations available, you can quickly add page borders that are appropriate for your project. Follow these steps to learn how to add a page border in Word or insert a border template.
This guide shows you how to add a border in Word. There are many settings and options to choose from that make it possible for you to configure the borders to look just the way you want them to.
You’ll also learn how to find and use Microsoft Word border templates to achieve a different look. You’ll discover great sources for Word border templates, as well as how to insert and set them up in your document.
How to Add Page Borders in Word (Quickstart Video)
Are you ready to dress up your Word documents with attractive page borders? The following video can give you a head start on how to add a page border in Word.
For more detailed info on how to insert page borders in Word plus some extra tips, review the tutorial below.
How to Add a Border in Microsoft Word
With just a few clicks of your mouse, you can create borders for Word documents.
To add a border in a Word document, go to Design > Page Borders.
The Borders and Shading panel opens.
From here, you’ve got several options, and the choices you make are the key for how to decorate a page border.
On the left-most part of the panel, pick the border Setting:
- None. This is the default setting. If you select this, there will be no border on the page.
- Box. This setting creates a line border on the page.
- Shadow. This creates a border with a shadow.
- 3-D. This creates a border that’s got depth.
- Custom. This setting lets you combine different types of borders for Microsoft Word on a single page or document.
As you make a selection, note that the Preview side of the panel shows you what the border will look like.
Here are some more detailed steps you can take to customize your border settings:
1. Set Custom Page Border Settings and Styles
In the next section of the Border and Shading panel, you can customize the various attributes of the border.
Choose from the many selections of:
- Style. Select a style for your border.
- Color. Specify a color for the border.
- Width. Change the thickness of the border.
- Art. This setting lets you create a border with built-in clip art. Scroll down to see all the art available.
By choosing from a variety of styles, colors, widths, and art, you can create a diverse assortment of borders. You don’t have to settle for any of the default settings for Word borders. You can create a border that perfectly aligns with your visual branding, the topic of your project, and the tone you wish to convey.
2. Remove Individual Border Lines
If you’ll recall, the Preview part of the Borders and Shading panel lets you see what the border will look like with the settings you selected.
This is also where you can specify where you would like the border to appear. It doesn’t have to be on all four sides of the page! Click on the buttons to select and de-select each side of the border. When a side is de-selected, then the border line doesn’t appear on that side.
For example, when I de-select the Left and Right Borders, they disappear from the Preview.
3. Where to Apply the Border
In the next part of the Borders and Shading panel, you specify which part of the Word document to apply the border you’ve just formatted.
These are the choices available to you:
- Whole document. This setting inserts the border on every page of your document.
- This section only. This setting inserts the border only in the current section you’re working in. You must create the section first for this option to be available.
- This section — First page only. This setting inserts the border only on the first page of the current section you’re working in. You must create the section first for this option to be available.
- This section — All except first page. This setting inserts the border on all the pages of the current section you’re working in, except the section’s first page. You must create the section first for this option to be available.
If you’re not yet familiar with sections, read this tutorial on how to create and use sections in Word.
4. Choose Border Options
There are more border attributes within your control!
Click on the Options button.
The Border and Shading Options panel opens. From here, you can set the Margins. This determines the amount of space between the border and the edge of the page, or the between the border and the text on the page.
The Border and Shading Options panel also has its own Preview section that shows you how your choices will affect the border. When you’re happy with the settings you’ve chosen, click OK.
Don’t worry, you can always go back and make changes to the border you’ve created.
How to Change a Page Border
There are so many options and settings to configure when you create a border. You may find that you want to change any of them after you’ve created the border. Follow these steps for how to change a page border you’ve made.
To edit a page border you’ve already created, go to Design > Page Borders.
This launches the Border and Shading Options panel. Adjust the attributes you want to change.
When you’re happy with the settings, click OK. The border has been modified, based on the changes you made.
Here are more instructions for changing borders:
Remove a Page Border in Word
Sometimes you add a border to your Word document … and then you change your mind. Maybe it doesn’t look good, or you simply decide that a plain and clean layout is better.
If this happens, don’t despair. Removing a page border in Word is easy.
To remove an existing border in Word, click Design > Page Borders.
Under Setting on the Border and Shading Options panel, click None.
The border has been removed.
How to Use a Word Border Template
You can also skip the design process altogether by using a Word border template.
The first step is to find a border image. Envato Elements is a terrific source of graphic images to use as a border in your Word project.
Sign into your Elements account.
In the search bar, select Graphics, then type “borders.” Click the search icon.
If you wish, you can refine the search results by using a filter and/or sorting the results.
To get more details about a particular border template, click on the thumbnail. This opens the product page.
From here, you can learn more about the image package:
- preview of the images included
- list of file types
- application requirements
- image dimensions
To download a border image, click on one of the Download buttons.
The Add this file to a project dialog opens.
Choose a project to add the file into or create a new project. Then, click Add & Download.
The files are downloaded and saved into your computer as a zip file. You may need to double-click on the zip file to unzip it. When unzipped, the border template files may come in separate folders, like these:
To insert the border into your Word project, click on Insert > Pictures > Picture from file….
Locate the border file you want to use, then click Insert.
The border has now been added to the page.
With the border image selected, use any of the buttons on the Picture Format ribbon to change the border.
In this example, let’s change the color of the border. Click on the Color button. The Color panel opens. Choose any of the preset Color Saturation, Color Tone, or Recolor options.
Or click More Variations > More Colors… to select a specific color that’s not on any of the Recolor choices.
For this example, I chose mustard yellow.
If you’re going to have text on the page, remember to change the text wrapping on the border image. Select the image, then click on Picture Format > Arrange > Wrap Text > Behind Text.
This means any text you add to the page will be visible on top of the border image and won’t get hidden beneath it.
Also, make sure to de-select Move with Text, which is checked by default. Fix Position on Page should be checked instead.
This ensures that the border stays in place even when you type text on the page.
Get an Extensive Selection of Templates for Word
Aside from border templates for Word documents, you can also find great Microsoft Word templates, graphics, fonts, stock photos, soundtracks, and other creative assets from Envato Elements.
Envato Elements a cost-effective source because for a fixed monthly subscription. You get unlimited downloads of any creative components. These are a big help when you need to create many Word projects and other communication materials.
But for one-off projects, GraphicRiver is a good alternative source for Microsoft Word templates and professional graphics. In the GraphicRiver marketplace, you pay per use. This a la carte approach means you only pay for what you download. So, if you’re working on a few projects, then this could be the more cost-effective source.
FAQs on Word
As you go over this tutorial, do you have questions about Word? Below are some of the most frequently asked questions about Word. I’ve included links to relevant articles to help you learn how to use Microsoft Word, even if you’re a complete beginner.
1. What’s MS Word Used For?
If you’re new to Word or have never used it for, you may wonder if you should even get started. Word is Microsoft’s desktop publishing software and it’s one of the most widely used computer applications in the world! Using Word, you can create all sorts of documents, both printed and web-based.
Even though some alternatives have cropped up — including free ones — MS Word continues to be popular in offices, homes, and schools.
2. Which Is Better, MS Word or Google Docs?
Google Docs is an alternative to MS Word that’s free and web-based. It offers many benefits, and you may wonder if it’s even better than Microsoft Word. As someone who uses both applications almost daily, all I can tell you is … it depends.
Either Word or Google Docs may be the best tool for the job — depending on what the job is! Read this post for the details.
3. Does Word Offer Clip Art?
Microsoft Word doesn’t have a built-in library of clip art. But it does allow you to browse and insert clip art from the web without ever leaving the application. You can also find clip art from sources like Envato Elements and GraphicRiver, and insert it into your Word project. This article shows you how to do all this, step by step.
4. Can I Change the Default Font in Word?
In a word, yes! Word lets you easily change the default Word and replace it with any of the fonts that come pre-installed. Or download professionally designed fonts in marketplaces like Envato Elements and GraphicRiver. This gives you total control over the design of your Word project. Click below for a full tutorial.
5. How Do You Add a Background Image in Word?
The procedure for inserting a background image in Word is just like adding a border image. Finding the right image, positioning it properly on the page, and applying the appropriate image effects will take your document’s design and layout to the next level — even if you’re not a professional designer. This article shows you how:
Spice Up Your Word Projects With Borders
To give your Word project a little oomph, try adding a border. Word lets you add a border that’s aligned with the style, tone, and design of your project. Whether your project is formal or whimsical, you’ll be able to add the appropriate border by calibrating the various options and settings available in Word.
Add a border in Word by using and customizing any of the preset styles. Follow the detailed steps above to learn how to create and change Word borders.
Another alternative is to insert a Word border template from Elements or GraphicRiver. Find Word templates in Elements if you’re a heavy user of Word. You’ll maximize your subscription because you get unlimited downloads for one monthly fee.
For a single Word document, GraphicRiver offers hundreds of templates for Word on a pay-per-use basis.
Whether you get them from Elements or GraphicRiver, border templates allow you to bring professional designs into your Word project. And with various modifications available to you, you’ll be transforming the templates into projects that are truly your own.
Editorial Note: This tutorial has been updated with a video from Andrew Childress.
Коллекция Borders и объекты Border показывают, как создать рамку в Word для заданного раздела, абзаца или текста в целом. В отличии от других объектов. Объекты Border предоставляют не общее количество рамок в документе, а только границы рамки, поясню…
Мы можем создать рамку в Word для заданного абзаца, тем самым получим доступ к коллекции Borders. Далее, нам нужно каждую границу рамки оформить в индивидуальный цвет, для этого, через метод Item(index) мы можем получить доступ к нужной границе данной рамки (верх, низ, правая или левая сторона), и уже потом, обработать ее в индивидуальном порядке.
Borders – как создать рамку в Word
Коллекция объектов Border, представляющих границы объекта Border. Мы можем как создать рамку в Word для заданного раздела, так и для абзаца или текста. Отсюда следует, что доступ к коллекции можно получить через свойство Borders, которое есть у следующих объектов:
Word Section – Создание рамки Word для заданного раздела.
Word Paragraph – Создание рамки Word для заданного абзаца.
Word Font, Range, Selection – В большинстве случает актуально использовать объект Font, так как он прямо говорит, что нужно применить рамку к тексту.
Свойства
Count — Возвращает количество объектов Border в коллекции Borders.
Enable – Свойство возвращает или устанавливает границы рамки в Word для заданного объекта. Может принимать логические значения true (установить рамку, заданную приложением по умолчанию), false (удалить рамку) или значения константы WdLineStyle.
DistanceFrom – Свойство возвращает или задает отступы для рамки. Применимо только для страниц! Значение константы WdBorderDistanceFrom:
- wdBorderDistanceFromPageEdge — 1 — С края страницы.
- wdBorderDistanceFromText — 0 — Начиная с текста.
DistanceFromBottom — Возвращает или задает отступ в пунктах между текстом и нижней границей рамки.
DistanceFromLeft — Возвращает или задает отступ в пунктах между текстом и левой границей рамки.
DistanceFromRight — Возвращает или задает отступ в пунктах между текстом и правой границей рамки Word.
DistanceFromTop — Возвращает или задает отступ в пунктах между текстом и верхней границей рамки.
Свойства EnableFirstPageInSection и EnableOtherPagesInSection всегда используются вместе, и, если одно свойство содержит значение true(false), то другое должно содержать противоположное значение, иначе, эффекта не будет.
EnableFirstPageInSection – Применить рамку только для первой страницы раздела. Возвращает или задает логические значения true или false. Только для страниц!
EnableOtherPagesInSection — Применить рамку для всех страниц раздела, кроме первой страницы. Возвращает или задает логические значения true или false. Только для страниц!
InsideColor и OutsideColor – Свойства возвращают или устанавливают 24 — битный цвет внутренних или внешних границ. Цвет можно задавать как с помощью функции RGB языка Visual Basic, так и с помощью значений константы wdColor. Как создать рамку в Word.
InsideColorIndex и OutsideColorIndex — Свойства возвращают или устанавливают цвет внутренних или внешних границ рамки в Word. Цвет можно задавать как с помощью функции RGB языка Visual Basic, так и с помощью значений константы WdColorIndex .
Свойства InsideLineStyle и OutsideLineStyle в большинстве случае должны использоваться вместе. Применять только свойство InsideLineStyle актуально тогда, если у нас выбрано несколько абзацев. Если мы применим данное свойство к одному абзацу, то возникнет ошибка.
InsideLineStyle и OutsideLineStyle – Свойства возвращают или устанавливают стиль внутренних или внешних границ для указанного объекта. Свойство может быть установлено в True, False или значение константы WdLineStyle. Как создать рамку в Word.
InsideLineWidth и OutsideLineWidth — Свойства возвращают или устанавливают ширину линии в пунктах для внутренней или внешней границы рамки. Свойство может быть установлено в True, False или значение константы WdLineWidth.
- wdLineWidth025pt — 2 — 0.25
- wdLineWidth050pt — 4 — 0.50
- wdLineWidth075pt — 6 — 0.75
- wdLineWidth100pt — 8 — 1.00
- wdLineWidth150pt — 12 — 1.50
- wdLineWidth225pt — 18 — 2.25
- wdLineWidth300pt — 24 — 3.00
- wdLineWidth450pt — 36 — 4.50
- wdLineWidth600pt — 48 — 6.00
Shadow – Возвращает или задает логическое значение, которое включает (true) или отключает (false) тени для рамки.
Методы
ApplyPageBordersToAllSections() — Применяет определенное ранее форматирование рамки в Word ко всем разделам документа.
Item(index) — Возвращает границу рамки для заданного диапазона или выделения. Параметр index содержит значение константы WdBorderType:
- wdBorderBottom — 3 — нижняя граница.
- wdBorderDiagonalDown — 7 — диагональная граница, начиная с верхнего — левого угла.
- wdBorderDiagonalUp — 8 — диагональная граница, начиная с нижнего — левого угла.
- wdBorderHorizontal — 5 — горизонтальные границы.
- wdBorderLeft — 2 – левая граница.
- wdBorderRight — 4 — правая граница.
- wdBorderTop — 1 — верхняя граница.
- wdBorderVertical — 6 — вертикальные границы
Border – как создать рамку в Word
Объект содержит только свойства
Свойства
Значения приведенных ниже константы смотрите в начале стать, в описании коллекции Borders.
ArtStyle — Возвращает или устанавливает графическое оформление рамки. Значение константы WdPageBorderArt. Только для страницы!
ArtWidth — Возвращает или задает ширину в пунктах для указанного графического оформления рамки в Word.
Color — Возвращает или устанавливает 24 — битный цвет рамки. Значение константы WdColor
ColorIndex — Возвращает или устанавливает цвет для указанной границы рамки. Значение константы WdColorIndex. Как создать рамку в Word.
Inside – Возвращает True, если внутренние границы могут быть применены к указанному объекту.
LineStyle — Возвращает или задает стиль линии границы. Значение константы WdLineStyle.
LineWidth — Возвращает или устанавливает ширину линии границы рамки в Word. Значение константы WdLineWidth.
Visible – Позволяет показать (true) или скрыть (false) рамку. Чтение и запись
Хорошо, теперь я приведу два примера кода на языке VBScript и JScript:
' ---------------------------------------------------------------------------- ' Коллекция Borders и объект Border ' Создание рамки в Word для текста, абзаца и раздела ' Borders.vbs ' ---------------------------------------------------------------------------- Option Explicit dim oWord, oDoc, oSel, i, oPars, MyText, oRange dim oParsRange, oParsRangeFont Set oWord = CreateObject("Word.Application") Set oDoc = oWord.Documents oDoc.Add() oWord.Visible = True Set oRange = oDoc(1).Range() Set oSel = oWord.Selection MyText = "Как создать рамку в Word. " For i=0 to 40 oSel.TypeText MyText & MyText & MyText & MyText & MyText & MyText & MyText oSel.TypeParagraph Next Set oPars = oRange.Paragraphs '--------------------------------------------------------------------------------------- ' Создаем рамку для первого абзаца и определяем отступы '--------------------------------------------------------------------------------------- oPars(1).Borders.Enable = true oPars(1).Borders.DistanceFromBottom = 15 oPars(1).Borders.DistanceFromLeft = 15 oPars(1).Borders.DistanceFromRight = 15 oPars(1).Borders.DistanceFromTop = 15 '--------------------------------------------------------------------------------------- '--------------------------------------------------------------------------------------- ' Создаем рамку для третьего абзаца ' определяем толщину и цвет границ '--------------------------------------------------------------------------------------- oPars(3).Borders.Enable = true oPars(3).Borders(1).LineWidth = 18 oPars(3).Borders(1).ColorIndex = 9 oPars(3).Borders(2).LineWidth = 18 oPars(3).Borders(2).ColorIndex = 10 oPars(3).Borders(3).LineWidth = 18 oPars(3).Borders(3).ColorIndex = 11 oPars(3).Borders(4).LineWidth = 18 oPars(3).Borders(4).ColorIndex = 12 '--------------------------------------------------------------------------------------- '--------------------------------------------------------------------------------------- ' Формируем ссылку на заданный диапазон ' Диапазон содержит выбор - от 5 по 10 абзацы ' Применяем форматирование к заданному выбору '--------------------------------------------------------------------------------------- Set oParsRange = oDoc(1).Range(oDoc(1).Paragraphs(5).Range.Start, oDoc(1).Paragraphs(10).Range.End) oParsRange.Borders.InsideLineStyle = 22 oParsRange.Borders.InsideLineWidth = 12 oParsRange.Borders.OutsideLineStyle = 23 oParsRange.Borders.OutsideLineWidth = 18 '--------------------------------------------------------------------------------------- '--------------------------------------------------------------------------------------- ' Применяем рамки к выбранному тексту '--------------------------------------------------------------------------------------- Set oParsRangeFont = oDoc(1).Range(oDoc(1).Paragraphs(13).Range.Start, oDoc(1).Paragraphs(15).Range.End) ' как создать рамку в Word oParsRangeFont.Font.Borders.Enable = 20 '--------------------------------------------------------------------------------------- ' Создаем рамку для всего раздела документа '--------------------------------------------------------------------------------------- For i = 1 to oDoc(1).Sections(1).Borders.Count oDoc(1).Sections(1).Borders(i).LineStyle =19 Next oDoc(1).Sections(1).Borders.ApplyPageBordersToAllSections '--------------------------------------------------------------------------------------- '--------------------------------------------------------------------------------------- ' Определяем новый стиль границ рамки и их ширину '--------------------------------------------------------------------------------------- oDoc(1).Sections(1).Borders(1).ArtStyle = 22 oDoc(1).Sections(1).Borders(1).ArtWidth = 10 '--------------------------------------------------------------------------------------- '--------------------------------------------------------------------------------------- ' Применяем рамку только для певой страницы раздела '--------------------------------------------------------------------------------------- oDoc(1).Sections(1).Borders.EnableFirstPageInSection = true oDoc(1).Sections(1).Borders.EnableOtherPagesInSection = false '---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------- // Коллекция Borders и объект Border // Создание рамки в Word для текста, абзаца и раздела // Borders.js // ---------------------------------------------------------------------------- var oWord, oDoc, oSel, i, oPars, MyText, j, oRange; var oParsRange, borderLoop, oParsRangeFont; oWord = WScript.CreateObject("Word.Application"); oDoc = oWord.Documents; oDoc.Add(); oWord.Visible = true; oRange = oDoc(1).Range(); oSel = oWord.Selection; MyText = "Как создать рамку в Word. "; for(i=0; i<=40; i++){ oSel.TypeText(MyText + MyText + MyText + MyText);// + MyText + MyText + MyText); oSel.TypeParagraph(); } oPars = oRange.Paragraphs; //--------------------------------------------------------------------------------------- // Создаем рамку для первого абзаца и определяем отступы //--------------------------------------------------------------------------------------- oPars(1).Borders.Enable = true; oPars(1).Borders.DistanceFromBottom = 15; oPars(1).Borders.DistanceFromLeft = 15; oPars(1).Borders.DistanceFromRight = 15; oPars(1).Borders.DistanceFromTop = 15; //--------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------- // Создаем рамку для третьего абзаца // определяем толщину и цвет границ //--------------------------------------------------------------------------------------- oPars(3).Borders.Enable = true; oPars(3).Borders(1).LineWidth = 18; oPars(3).Borders(1).ColorIndex = 9; oPars(3).Borders(2).LineWidth = 18; oPars(3).Borders(2).ColorIndex = 10; oPars(3).Borders(3).LineWidth = 18; oPars(3).Borders(3).ColorIndex = 11; oPars(3).Borders(4).LineWidth = 18; oPars(3).Borders(4).ColorIndex = 12; //--------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------- // Формируем ссылку на заданный диапазон // Диапазон содержит выбор - от 5 по 10 абзацы // Применяем форматирование к заданному выбору //--------------------------------------------------------------------------------------- oParsRange = oDoc(1).Range(oDoc(1).Paragraphs(5).Range.Start, oDoc(1).Paragraphs(10).Range.End); oParsRange.Borders.InsideLineStyle = 22; oParsRange.Borders.InsideLineWidth = 12; oParsRange.Borders.OutsideLineStyle = 23; oParsRange.Borders.OutsideLineWidth = 18; //--------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------- // Применяем рамки к выбранному тексту //--------------------------------------------------------------------------------------- oParsRangeFont = oDoc(1).Range(oDoc(1).Paragraphs(13).Range.Start, oDoc(1).Paragraphs(15).Range.End); // как создать рамку в Word oParsRangeFont.Font.Borders.Enable = 20; //--------------------------------------------------------------------------------------- // Создаем рамку для всего раздела документа //--------------------------------------------------------------------------------------- for(i = 1; i<=oDoc(1).Sections(1).Borders.Count; i++){ oDoc(1).Sections(1).Borders(i).LineStyle =19; } oDoc(1).Sections(1).Borders.ApplyPageBordersToAllSections(); //--------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------- // Определяем новый стиль границ рамки и их ширину //--------------------------------------------------------------------------------------- oDoc(1).Sections(1).Borders(1).ArtStyle = 22; oDoc(1).Sections(1).Borders(1).ArtWidth = 10; //--------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------- // Применяем рамку только для певой страницы раздела //--------------------------------------------------------------------------------------- oDoc(1).Sections(1).Borders.EnableFirstPageInSection = true; oDoc(1).Sections(1).Borders.EnableOtherPagesInSection = false; //---------------------------------------------------------------------------------------
Видим, что программный код получался довольно объемным, да и сама статья тоже не маленькая. Не буду вникать в описание сценариев, так как описание я дал в самих комментариях. Скажу лишь, что после запуска сценария будет создан документ с заданным текстом, некоторые абзацы и первая страница будут отформатированы — в виде различных рамок.