removing the X from the userform

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
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:

<pre>

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</pre>

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.

<pre>
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</pre>

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
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,037
Members
449,062
Latest member
mike575

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top