WordBasic Examples: AppWindowHeight/Width/PosLeft/PosTop

Last reviewed: July 30, 1997
Article ID: Q106190
The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, version 7.0

SUMMARY

This article contains an example that demonstrates the use of the following WordBasic statements or functions:

   AppWindowHeight   AppWindowHeight()

   AppWindowPosLeft  AppWindowPosLeft()

   AppWindowPosTop   AppWindowPosTop()

   AppWindowWidth    AppWindowWidth()

Note: On the Macintosh, these commands are not available and will generate errors.

This article supplements the information in online Help. To open this Help topic, choose Contents from the Help menu and then choose the "Programming with Microsoft Word" topic.

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

AppWindowHeight, AppWindowHeight()

Syntax

AppWindowHeight [WindowName$,] Height AppWindowHeight([WindowName$])

Example

The AppWindowHeight statement adjusts the height of an application window to a specified number of points (if WindowName$ is omitted, Word is assumed). AppWindowHeight allows you to change the height of a window without affecting its width (unlike AppSize). The AppWindowHeight() function returns the height of an application window in points. For argument descriptions, see AppSize.

Sub MAIN
   x = 0
   state = AppMaximize()
   If state = - 1 Then AppRestore
   x = AppWindowHeight()
   MsgBox "The height of this window is: " + Str$(x)
   AppWindowHeight x - 100
   MsgBox "The height of this window is: " + Str$(x - 100)
End Sub

AppWindowPosLeft, AppWindowPosLeft()

Syntax

AppWindowPosLeft [WindowName$,] HorizPos AppWindowPosLeft([WindowName$])

Example

The AppWindowPosLeft statement moves an application window or icon to a horizontal position specified in points (if WindowName$ is omitted, Word is assumed). AppWindowPosLeft allows you to change the horizontal position of a window or icon without affecting its vertical position (unlike AppMove). The AppWindowPosLeft() function returns the horizontal position of an application window or icon, in points. For argument descriptions, see AppMove.

Sub MAIN
   state = AppMaximize()
   If state = - 1 Then AppRestore
   x = AppWindowPosLeft()
   MsgBox "The distance from the left is: " + Str$(x)
   AppWindowPosLeft x + 100
   MsgBox "The distance from the left is: " + Str$(x +100)
End Sub

AppWindowPosTop, AppWindowPosTop()

Syntax

AppWindowPosTop [WindowName$,] VertPos AppWindowPosTop([WindowName$])

Example

The AppWindowPosTop statement moves an application window or icon to a vertical position specified in points (if WindowName$ is omitted, Word is assumed). AppWindowPosTop allows you to change the vertical position of a window or icon without affecting its horizontal position (unlike AppMove). The AppWindowPosTop() function returns the vertical position of an application window or icon, in points. For argument descriptions, see AppMove.

Sub MAIN
   x = 0
   state = AppMaximize()
   If state = - 1 Then AppRestore
   x = AppWindowPosTop()
   MsgBox "The distance from the top is: " + Str$(x)
   AppWindowPosTop x + 100
   MsgBox "The distance from the top is: " + Str$(x + 100)
End Sub

AppWindowWidth, AppWindowWidth()

Syntax

AppWindowWidth [WindowName$,] Width AppWindowWidth([WindowName$])

Example

The AppWindowWidth statement adjusts the width of an application window to a specified number of points (if WindowName$ is omitted, Word is assumed). AppWindowWidth allows you to change the width of a window without affecting its height (unlike AppSize). The AppWindowWidth() function returns the width of an application window, in points. For argument descriptions, see AppSize.

Sub MAIN
   x = 0
   state = AppMaximize()
   If state = - 1 Then AppRestore
   x = AppWindowWidth()
   MsgBox "The width of this window is: " + Str$(x)
   AppWindowWidth x / 2
   MsgBox "The width of this window is: " + Str$(x / 2)
End Sub

Kbcategory: kbusage kbmacro KBSubcategory: kbmacroexample


Additional query words: 6.0 winword word6 6.0a 6.0c 7.0 word95
word7

Keywords : kbmacroexample
Version : 6.0 6.0a 6.0c 7.0
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.