Applies To
Application Object, Arc Object, Arcs Collection, Button Object, Buttons Collection, ChartArea Object, ChartObject Object, ChartObjects Collection, CheckBox Object, DialogFrame Object, Drawing Object, DrawingObjects Collection, Drawings Collection, DropDown Object, DropDowns Collection, EditBox Object, EditBoxes Collection, GroupBox Object, GroupBoxes Collection, GroupObject Object, GroupObjects Collection, Label Object, Labels Collection, Legend Object, Line Object, Lines Collection, ListBox Object, ListBoxes Collection, OLEObject Object, OLEObjects Collection, OptionButton Object, OptionButtons Collection, Oval Object, Ovals Collection, Picture Object, Pictures Collection, PlotArea Object, Range Object, Rectangle Object, Rectangles Collection, ScrollBar Object, ScrollBars Collection, Spinner Object, Spinners Collection, TextBox Object, TextBoxes Collection, Toolbar Object, ToolbarButton Object, Window Object.
Description
Returns or sets an object's width in points (1/72 inch). Read-write for all objects, except Range, which is read-only.
Remarks
The Width property has several different meanings, depending on the object to which it is applied.
Object |
Description |
Application |
The distance from the left edge of the application window to the right edge of the application window. |
Range |
The width of the range. |
Toolbar |
The width of the toolbar. When you set the width, Microsoft Excel snaps both the width and the height to match the nearest allowable size. |
Window |
The width of the window. Use the UsableWidth property to determine the maximum size for the window. You cannot set this property if the window is maximized or minimized. Use the WindowState property to determine the window state. |
Arc, Button, ChartArea, CheckBox, DialogFrame, Drawing, DrawingObjects, DropDown, EditBox, GroupBox, GroupObject, Label, Legend, Line, ListBox, OLEObject, OptionButton, Oval, Picture, PlotArea, Rectangle, ScrollBar, Spinner, TextBox, ToolbarButton, Window |
The width of the object. If you set the width for an entire collection of objects (using Ovals.Width = 100, for example), the width of each object changes in proportion to its existing width (this mimics the behavior of selecting all the objects and then dragging a handle to change the width of the selection). This means that the width of each object changes, but they are not all set to the same width. To set every object in the collection to the same width, you must iterate the collection and set the width of each individual object. |
On the Apple Macintosh, Application.Width is always equal to the total width of the screen, in points. Setting this value to any other value will have no effect.
In Microsoft Windows, if the window is minimized, Application.Width is read-only and returns the width of the icon.
You can use negative numbers to set the Height and Width properties of the following drawing objects: Arc, Button, CheckBox, Drawing, DropDown, EditBox, GroupBox, GroupObject, Label, Line, ListBox, OLEObject, OptionButton, Oval, Picture, Rectangle, ScrollBar, Spinner, and TextBox. This causes the object to reflect or translate (the behavior depends on the object), after which the Top and Left properties change to describe the new position. The Height and Width properties always return positive numbers.
See Also
Top Property.
Example
This example sets the width of oval one on Sheet1 to 1 inch (72 points).
Worksheets("Sheet1").Ovals(1).Width = 72
This example sets the width of every button on Sheet1 to 36 points.
For Each b In Worksheets("Sheet1").Buttons b.Width = 36 Next b
This example expands the active window to the maximum size available (assuming that the window is not maximized).
With ActiveWindow .WindowState = xlNormal .Top = 1 .Left = 1 .Height = Application.UsableHeight .Width = Application.UsableWidth End With