Width Property

Microsoft Word Visual Basic

Frameset object: Returns or sets the width of the specified Frameset object. Read/write Long. The WidthType property determines the type of unit in which this value is expressed.

All other objects: Returns or sets the width of the specified object, in points. Read/write Long.

Example

This example creates a 5x5 table in a new document and then sets the width of the first cell to 1.5 inches.

Set newDoc = Documents.Add
Set myTable = _
    newDoc.Tables.Add(Range:=Selection.Range, NumRows:=5, _
    NumColumns:=5)
myTable.Cell(1, 1).Width = InchesToPoints(1.5)
		

This example returns the width (in inches) of the cell that contains the insertion point.

If Selection.Information(wdWithInTable) = True Then
    MsgBox PointsToInches(Selection.Cells(1).Width)
End If
		

This example formats the section that includes the selection as three columns. The For Each...Next loop is used to display the width of each column in the TextColumns collection.

Selection.PageSetup.TextColumns.SetCount NumColumns:=3
For Each acol In Selection.PageSetup.TextColumns
    MsgBox "Width= " & PointsToInches(acol.Width)
Next acol
		

This example sets the width and height of the Microsoft Word application window.

With Application
    .WindowState = wdWindowStateNormal
    .Width = 500
    .Height = 400
End With
		

This example sets the width of the specified Frameset object to 25% of the window width.

With ActiveWindow.ActivePane.Frameset
    .WidthType = wdFramesetSizeTypePercent
    .Width = 25
End With