VBA Code

With Selection.Cells 
   .Borders(wdBorderType.wdBorderLeft).LineStyle = wdLineStyle.wdLineStyleNone

   With .Borders(wdBorderType.wdBorderRight)
      .LineStyle = wdLineStyle.wdLineStyleSingle
      .LineWidth = wdLineWidth.wdLineWidth075pt
      .ColorIndex = wdColorIndex.wdAuto
   End With

   With .Borders(wdBorderType.wdBorderTop)
      .LineStyle = wdLineStyle.wdLineStyleSingle
      .LineWidth = wdLineWidth.wdLineWidth075pt
      .ColorIndex = wdColorIndex.wdAuto
   End With

   With .Borders(wdBorderType.wdBorderBottom)
      .LineStyle = wdLineStyle.wdLineStyleSingle
      .LineWidth = wdLineWidth.wdLineWidth075pt
      .ColorIndex = wdColorIndex.wdAuto
   End With

   .Borders.Shadow = False
End With


Different objects have different borders
A border can be defined by using three properties.
You must always set the LineStyle first
LineStyle -
LineWidth -
Color -


objCharacters 
objParagraphFormat
objRange
objSection
objSelection
objTable
objTableStyle
objFont.Borders(wdBorderType)
objFrame
objParagraph.Borders(wdBorderType)
objRow
objColumn
objCell.Borders(wdBorderType)
objStyle.Borders(wdBorderType)

Not every linestyle is available in every width
If you choose a linewidth which is not compatible with the line style you will get an error.


Borders.Visible

You can set the visible property of a border.
This is the equivalent to setting the linestyle to wdLineStyleNone

objSelection.Borders(wdBorderTop).Visible = False 
objSelection.Borders(wdBorderTop).LineStyle = wdLineStyleNone

If you set the visible property to True a black wdLineStyleSingle border is applied
The LineWidth is a bit hit and miss



Removing all Borders

The quickest way is to use the Enabled property

objSelection.Borders.Enable = False 

This removes all the borders
This property however will not remove diagonal borders from a table or table style object.


Enabled Property

This returns wdConstants.wdUndefined if border formatting is applied to all or part of the object.
This applies to all borders of the specified object
True - sets the linestyle to the default line style and the line width to the default line width.



Default Line Style and Width

These can be set using

Options.DefaultBorderLineWidth = 
Options.DefaultBorderLineStyle =

Outside Borders

These are the top, right, bottom and left borders of an object
OutsideLineStyle
OutsideLineWidth
OutsideColor



Inside Borders

InsideLineStyle
InsideLineWidth
InsideColor



If the line style = wdlinestylenone
then what is the color and linewidth




© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrev