Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Declare Function SetTimer Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, _
ByVal nIDEvent As Long) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function GetWindowRect Lib "user32" _
(ByVal hwnd As Long, lpRect As RECT) As Long
Declare Function SetWindowPos Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Const SM_CXSCREEN = 0
Const SWP_NOSIZE = &H1
Const SWP_NOACTIVATE = &H10
Const SWP_NOZORDER = &H4
Dim lngTimerID As Long
Sub ShowDialogue()
lngTimerID = SetTimer(0, 0, 1, AddressOf TimerProc)
Application.DisplayAlerts = False
ActiveSheet.ShowDataForm
End Sub
Sub TimerProc()
Dim rectDlgPos As RECT
Dim lngDialogWidth As Long
Dim lngScreenWidth As Long
lngStaticTextHwnd = FindWindow("bosa_sdm_XL9", vbNullString)
GetWindowRect lngStaticTextHwnd, rectDlgPos
lngScreenWidth = GetSystemMetrics(SM_CXSCREEN)
lngDialogWidth = (rectDlgPos.Right - rectDlgPos.Left)
SetWindowPos lngStaticTextHwnd, 0, lngScreenWidth - lngDialogWidth _
, 0, 0, 0, SWP_NOSIZE Or SWP_NOZORDER Or SWP_NOACTIVATE
KillTimer 0, lngTimerID
End Sub
Sub Customise_DataForm()
CommandBars.FindControl(ID:=860).OnAction = "CustomProc"
End Sub
Sub CustomProc()
ShowDialogue
End Sub
Sub Reset_DataForm()
CommandBars.FindControl(ID:=860).Reset
End Sub