Thanks Thanks:  0
Likes Likes:  0
Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: removing the X from the userform

  1. #11
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Christchurch New Zealand
    Posts
    1,030
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    sorry mark but that doesn't seem to work probably because im using office xp
    thanks anyway.

  2. #12
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    OK, here's what I want you to do.

    1. Open a new Excel Workbook.
    2. Add a Userform
    3. Add a Textbox to the userform called "TextBox1"
    4. Put this code onto the userform:



    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
    'Private Declare Function FindWindow& Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String)
    Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)

    Private Sub UserForm_Initialize()
    Dim lpClassName As String
    Dim hwnd As Long, lresult As Long
    lpClassName = Space(256)
    hwnd = FindWindow(vbNullString, Me.Caption)
    lresult = GetClassName(hwnd, lpClassName, 256)
    txtClassname = Left$(lpClassName, lresult)

    Me.Textbox1.Text = txtClassname
    End Sub


    5. Run the userform. Hopefully the Textbox will say something other than "ThunderDForm"

    6. In the code I gave you before, put this code in in place of hte "If...Then" statement which compares the Application Version numbers. Change the "Case Else" part of this code that says "TextBox1's Contents" to whatever the text is in TextBox1.


    Select Case Val(Application.Version)

    Case 8
    hWndForm = FindWindow("ThunderXFrame", Me.Caption) 'XL97
    Case 9
    hWndForm = FindWindow("ThunderDFrame", Me.Caption) 'XL2000
    Case Else
    hWndForm = FindWindow("TextBox1's Contents", Me.Caption) 'XL2000
    End Select


    7. Tell me the name that is in TextBox1 because I don't have Office XP and I am interested to find out what the Userform ClassName is now.

    HTH



Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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