'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Begin Rick Rothstein @ ExcelFox.com
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'**** Start of API Calls To Remove The UserForm's Title Bar ****
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long
'**** End of API Calls To Remove The UserForm's Title Bar ****
'**** Start of API Calls To Allow User To move UserForm Around The Screen ****
'******************************************************************************
' Reenable these declarations AND the code in UserForm_MouseDown to enable '<--- Currently enabled during debugging
' movement of frmSearchTags on the screen
'******************************************************************************
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
'**** End of API Calls To Allow User To Slide UserForm Around The Screen ****
Dim hWndForm As Long
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' End Rick Rothstein ExcelFox.com
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Being Chip Pearson
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Declare Function SetParent Lib "user32" ( _
ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This declaration was done above in the code from Rick Rothstein. Leaving it in place in case there is a need
' to copy only the code of Chip Pearson to another module - so that this code will be complete.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
' ByVal lpClassName As String, _
' ByVal lpWindowName As String) As Long
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _
ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long
Private Declare Function GetAncestor Lib "user32.dll" ( _
ByVal hwnd As Long, ByVal gaFlags As Long) As Long
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' End Chip Pearson
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub cbTags_Change()
Dim tags As String
Dim tagsColumn As Range
cbTags.HideSelection = True
Set tagsColumn = Range("TagsColumn")
tag = cbTags
ActiveSheet.Range("TableData").AutoFilter Field:=tagsColumn.Column, Criteria1:="*" & tag & "*"
End Sub
Private Sub CommandButton1_Click()
cbTags.SetFocus
MsgBox "This functionality is disabled during testing"
End Sub
Private Sub CommandButton2_Click()
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Turn off all filters and position begining of chart
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
cbTags.SetFocus
frmSearchTags.cbTags = ""
ActiveSheet.AutoFilterMode = False
End Sub
Private Sub UserForm_Initialize()
Dim Style As Long, Menu As Long '< Rick Rothstein @ ExcelFox.com
Dim pointcoordinates As pointcoordinatestype, horizontaloffsetinpoints As Double, verticaloffsetinpoints As Double '< Yin Cognyto
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Begin GrouchySmurf <== Only using GrouchySmurf coding to try to find SOMETHING that works to assign position.
'* Ultimately, only one code set from GrouchySmurf, Yin Cognyto or other would be user.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim AppXPoint, AppYPoint As Long
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' End GrouchySmurf
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Begin Chip Pearson to make form a child of worksheet
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Const C_VBA6_USERFORM_CLASSNAME = "ThunderDFrame"
Dim AppHWnd As Long
Dim DeskHWnd As Long
Dim WindowHWnd As Long
Dim MeHWnd As Long
Dim Res As Long
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' End Chip Pearson
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Begin Rick Rothstein @ ExcelFox.com to hide menu bar
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
hWndForm = FindWindow("ThunderDFrame", Me.Caption)
Style = GetWindowLong(hWndForm, &HFFF0)
Style = Style And Not &HC00000
SetWindowLong hWndForm, &HFFF0, Style
DrawMenuBar hWndForm
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' End Rick Rothstein @ ExcelFox.com
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Begin Chip Pearson to make form a child of worksheet
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
AppHWnd = FindWindow("XLMAIN", Application.Caption)
If AppHWnd > 0 Then
' get the window handle of the Excel desktop
DeskHWnd = FindWindowEx(AppHWnd, 0&, "XLDESK", vbNullString)
If DeskHWnd > 0 Then
' get the window handle of the ActiveWindow
WindowHWnd = FindWindowEx(DeskHWnd, 0&, "EXCEL7", ActiveWindow.Caption)
If WindowHWnd > 0 Then
' ok
Else
MsgBox "Unable to get the window handle of the ActiveWindow."
End If
Else
MsgBox "Unable to get the window handle of the Excel Desktop."
End If
Else
MsgBox "Unable to get the window handle of the Excel Application."
End If
' get the window handle of the userform
MeHWnd = FindWindow(C_VBA6_USERFORM_CLASSNAME, Me.Caption)
If (MeHWnd > 0) And (WindowHWnd > 0) Then
' make the userform a child window of the ActiveWindow
Res = SetParent(MeHWnd, WindowHWnd)
If Res = 0 Then
''''''''''''''''''''
' an error occurred.
''''''''''''''''''''
MsgBox "The call to SetParent failed."
End If
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' End Chip Pearson
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Begin Yin Cognyto to position userform correctly
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With Me
ActiveSheet.Range("A1").Select '<--Tom. To reset where the control form is located
horizontaloffsetinpoints = (.Width - .InsideWidth) / 2
verticaloffsetinpoints = 1
Call GetPointCoordinates(ActiveCell, pointcoordinates)
.StartUpPosition = 0
.Top = pointcoordinates.Top - verticaloffsetinpoints
.Left = pointcoordinates.Left - horizontaloffsetinpoints
End With
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' End Yin Cognyto
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'<---- Begin Debugging
Debug.Print "Post Yin Gognyto:"
Debug.Print "-- left set to " & (pointcoordinates.Left - horizontaloffsetinpoints) & " --> result = " & Me.Left & ". Difference = " & (Me.Left - (pointcoordinates.Left - horizontaloffsetinpoints))
Debug.Print "-- top set to " & (pointcoordinates.Top - verticaloffsetinpoints) & " --> result = " & Me.Top & ". Difference = " & (Me.Top - (pointcoordinates.Top - verticaloffsetinpoints))
'<---- End Debugging
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Begin GrouchySmurf --> Another attempt at positioning userform
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'AppXPoint = Application.Left + (Application.Width - Me.Width) '<---- GrouchySmurf
'AppYPoint = Application.Top
AppXPoint = Application.Left + 10 '<---- Tom Brock --> arbitrary postioning to test setting .left and .top
AppYPoint = Application.Top + 126
With Me
.StartUpPosition = 0
.Left = AppXPoint
.Top = AppYPoint
End With
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' End GrouchySmurf --> Another attempt at positioning userform
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'<---- Begin Debugging
Debug.Print "Post GrouchySmurf:"
Debug.Print "-- left set to " & AppXPoint & " --> result = " & Me.Left & ". Difference = " & (Me.Left - (AppXPoint))
Debug.Print "-- top set to " & AppYPoint & " --> result = " & Me.Top & ". Difference = " & (Me.Top - (AppYPoint))
'<---- End Debugging
Me.Show
End Sub
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'***************************************************************************************************
' Begin Rick Rothstein @ Excelfox.com coding to allow movement of this (Userform2) with the mouse
'
' I had this DISABLED but it is temporarily enabled to allow me to correctly position the userform
'***************************************************************************************************
If Button = xlPrimaryButton Then
Call ReleaseCapture
Call SendMessage(hWndForm, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0&)
End If
'***************************************************************************************************
' End Rick Rothstein Excelfox.com coding
'***************************************************************************************************
End Sub