+ Reply to Thread
Results 1 to 4 of 4

How to control the UserForm's position?

  1. #1
    OKLover
    Guest

    How to control the UserForm's position?

    Hello, All

    Is anyone knows how to control the UserForm's position?
    It seems that i couldn't to find the Screen.Width or Screen.Height property
    in VBA.



  2. #2
    Bob Phillips
    Guest

    Re: How to control the UserForm's position?

    Try this

    http://www.cpearson.com/excel/FormPosition.htm

    --
    HTH

    Bob Phillips

    "OKLover" <[email protected]> wrote in message
    news:%[email protected]...
    > Hello, All
    >
    > Is anyone knows how to control the UserForm's position?
    > It seems that i couldn't to find the Screen.Width or Screen.Height

    property
    > in VBA.
    >
    >




  3. #3
    Harald Staff
    Guest

    Re: How to control the UserForm's position?

    There is no Screen object like in VB, and Excel's metrics is not pixels
    either -at least not all over. But this places the userform down right on my
    screen, no matter what and where the Excel window is:

    Declare Function GetSystemMetrics32 Lib "user32" _
    Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long

    Public Const SM_CXSCREEN = 0
    Public Const SM_CYSCREEN = 1

    Sub test()
    Dim X As Long, Y As Long
    X = GetSystemMetrics32(SM_CXSCREEN)
    Y = GetSystemMetrics32(SM_CYSCREEN)
    With UserForm1
    ..StartUpPosition = 0
    ..Top = (Y - .Height - 50) * 0.71
    ..Left = (X - .Width - 50) * 0.71
    ..Show
    End With
    End Sub

    Code modified from http://www.j-walk.com/ss/excel/tips/tip06.htm

    HTH. Best wishes Harald

    "OKLover" <[email protected]> skrev i melding
    news:%[email protected]...
    > Hello, All
    >
    > Is anyone knows how to control the UserForm's position?
    > It seems that i couldn't to find the Screen.Width or Screen.Height
    > property in VBA.
    >




  4. #4
    OKLover
    Guest

    Re: How to control the UserForm's position?

    Thanks to Bob and Harald, i will try it. :D


    "OKLover" <[email protected]> 写入消息新闻:%[email protected]...
    > Hello, All
    >
    > Is anyone knows how to control the UserForm's position?
    > It seems that i couldn't to find the Screen.Width or Screen.Height
    > property in VBA.
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1