Class TextColumns (Word VBA)

To use a TextColumns class variable it first needs to be instantiated, for example


Dim tcs as TextColumns
Set tcs = ActiveDocument.PageSetup.TextColumns

For Each

Here is an example of processing the TextColumns items in a collection.


Dim tcn As TextColumn
For Each tcn In ActiveDocument.PageSetup.TextColumns
	
Next tcn

Add

Returns a TextColumn object that represents a new text column added to a section or document.

Add (Width, Spacing, EvenlySpaced)


Set myDoc = Documents.Add 
myDoc.PageSetup.TextColumns.Add Width:=InchesToPoints(2.5), _ 
 Spacing:=InchesToPoints(0.5), EvenlySpaced:=False

Arguments

Optional arguments

The following arguments are optional

Width (Long) - The width of the new text column in the document, in points.

Spacing (Long) - The spacing between the text columns in the document, in points.

EvenlySpaced (Boolean) - True to evenly space all the text columns be in the document.

Count

Returns a Long that represents the number of text columns in the collection.


Dim lngCount As Long
lngCount = ActiveDocument.PageSetup.TextColumns.Count

EvenlySpaced

True if text columns are evenly spaced.

The EvenlySpaced property can be True, False, or wdUndefined. If you set the Spacing or Width property of the TextColumns object, the EvenlySpaced property is automatically set to True. Also, setting the EvenlySpaced property may change the settings for the Spacing and Width properties of the TextColumns object.


Dim colTextColumns 
 
Set colTextColumns = ActiveDocument.PageSetup.TextColumns 
 
If colTextColumns.Count > 1 Then _ 
 colTextColumns.EvenlySpaced = True 
End If

FlowDirection

Returns or sets the direction in which text flows from one text column to the next. Possible return values are wdFlowLtr - Text in columns flows from left to right, wdFlowRtl - Text in columns flows from right to left.


ActiveDocument.PageSetup.TextColumns.FlowDirection = _ 
 wdFlowRtl

Item

Returns an individual TextColumn object in a collection.

Item (Index)

Index: The individual object to be returned. Can be a Long indicating the ordinal position of the individual object.


Dim tcn As TextColumn
Set tcn = ActiveDocument.PageSetup.TextColumns(Index:=1)

LineBetween

True if vertical lines appear between all the columns in the TextColumns collection.

The LineBetween property can be True, False, or wdUndefined.


i = 1 
For each s in ActiveDocument.Sections 
 If s.PageSetup.TextColumns.LineBetween = True Then 
 MsgBox "The columns in section " & i & " contain lines." 
 End If 
 i = i + 1 
Next s

SetCount

Arranges text into the specified number of text columns.

You can also use the Add method to add a single column to the TextColumns collection.

SetCount (NumColumns)

NumColumns: The number of columns the text is to be arranged into.


ActiveDocument.PageSetup.TextColumns.SetCount NumColumns:=2

Spacing

Returns or sets the spacing (in points) between columns.

After this property has been set for a TextColumns object, the EvenlySpaced property is set to True. To return or set the spacing for a single text column when EvenlySpaced is False, use the SpaceAfter property of the TextColumn object.


With ActiveDocument.PageSetup.TextColumns 
 .SetCount NumColumns:=2 
 .LineBetween = False 
 .EvenlySpaced = True 
 .Spacing = 36 
End With

Width

Returns or sets the width of the Word art text effects, in points.


ActiveDocument.PageSetup.TextColumns.Width =