Microsoft KB Archive/103707

= Microsoft Knowledge Base =

Excel: Using GET.WORKSPACE to Determine Screen Element Size
Last reviewed: September 12, 1996

Article ID: Q103707

The information in this article applies to:


 * Microsoft Excel for Windows, versions 3.0, 4.0, 4.0a, 5.0
 * Microsoft Excel for the Macintosh, versions 3.0, 4.0

SUMMARY
When you develop a custom application in Microsoft Excel that will run on machines with different screen resolutions, it may be useful to determine the amount of space that different workspace elements such as the menu bar, formula bar, status bar and/or toolbar will use. After determining the amount of space these elements use, you can then determine how and where to position documents and which of these elements you want to be displayed.

Use the GET.WORKSPACE macro command to determine the element size. This command takes a type_num argument which specifies the type of workspace information you want; specifying a type_num of 13 returns the usable workspace width and 14 returns the usable workspace height. You can determine the the size of an individual workspace element with GET.WORKSPACE(13) or GET.WORKSPACE(14) before and after you remove the element from the workspace. (Note: this is true for version 5.0 macro sheets, but not modules.)

Example
For example, if you want to determine the height of the status bar, use GET.WORKSPACE(14) before and after disabling the status bar with the WORKSPACE macro command.

The following macro will return the height of the status bar and display it in an alert box.

A1: Status_Height A2: =WORKSPACE(,,,,FALSE) A3: nostatusbar=GET.WORKSPACE(14) A4: =workspace(,,,,TRUE) A5: statusbar=GET.WORKSPACE(14) A6: statusbarheight=nostatusbar-statusbar A7: =ALERT("The height of the status bar in points is "&statusbarheight) A7: =RETURN

Microsoft provides macro examples for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.