Private m_clsCombo1 As clsControlCombo
Private m_clsCombo2 As clsControlCombo
Private m_clsCombo3 As clsControlCombo
Private m_clsCombo4 As clsControlCombo
Private m_clsCombo5 As clsControlCombo
Private m_clsCombo6 As clsControlCombo
Private Declare Function GetActiveWindow Lib _
"user32" () As Integer
Private Declare Function SetActiveWindow Lib _
"user32" (ByVal HWnd As Long) As Integer
Private Declare Function GetForegroundWindow Lib _
"user32" () As Long
Private Declare Function SetForegroundWindow Lib _
"user32" (ByVal HWnd As Long) As Integer
Private 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
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
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
Dim appWd As Word.Application
Dim doc As Word.Document
Dim rng As Word.Range
Dim aryTlb() As String
Dim cntTlb As Integer
Dim aryFT() As String
Dim aryFL() As String
Dim aryFC() As String
Dim aryST() As String
Dim arySL() As String
Dim arySC() As String
Dim arySongs(100) As String
Dim cntSongs As Integer
Dim x As Integer
Dim bolChgMe As Boolean
Dim bolNoSong As Boolean
Dim bolTwoMon As Boolean
Dim bolSongCls As Boolean
Dim bolFirstLet As Boolean
Dim XX
Dim frmTop As Long
Dim frmLeft As Long
Dim ScreenArea 'As RECT
Dim MyHwnd
''
Private m_clsCombo1 As clsControlCombo
Private m_clsCombo2 As clsControlCombo
Private m_clsCombo3 As clsControlCombo
Private m_clsCombo4 As clsControlCombo
Private m_clsCombo5 As clsControlCombo
Private m_clsCombo6 As clsControlCombo
Private Declare Function GetActiveWindow Lib _
"user32" () As Integer
Private Declare Function SetActiveWindow Lib _
"user32" (ByVal HWnd As Long) As Integer
Private Declare Function GetForegroundWindow Lib _
"user32" () As Long
Private Declare Function SetForegroundWindow Lib _
"user32" (ByVal HWnd As Long) As Integer
Private 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
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
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
Dim appWd As Word.Application
Dim doc As Word.Document
Dim rng As Word.Range
Dim aryTlb() As String
Dim cntTlb As Integer
Dim aryFT() As String
Dim aryFL() As String
Dim aryFC() As String
Dim aryST() As String
Dim arySL() As String
Dim arySC() As String
Dim arySongs(100) As String
Dim cntSongs As Integer
Dim x As Integer
Dim bolChgMe As Boolean
Dim bolNoSong As Boolean
Dim bolTwoMon As Boolean
Dim bolSongCls As Boolean
Dim bolFirstLet As Boolean
Dim XX
Dim frmTop As Long
Dim frmLeft As Long
Dim ScreenArea 'As RECT
Dim MyHwnd
'
'************
'
Private Sub Text1_KeyPress(KeyAscii As Integer)
XX = KeyAscii
Dim idx
Dim strList As String
Dim strFile As String
If KeyAscii = 48 Then ' Typed zero, close top Word doc
'Stop
If appWd.Documents.Count > 0 Then
appWd.Documents(1).Close
bolSongCls = True
GoTo SongClosed
End If
End If
If KeyAscii < 33 Then Exit Sub
If KeyAscii > 95 Then Exit Sub
If KeyAscii > 64 And KeyAscii < 91 Then Exit Sub
If Me.Text1.Text = "" Then bolNoSong = True
If InStr(1, Me.Text1.Text, "=") > 0 Then bolNoSong = True
Select Case XX
Case 33 'SHIFT+1 = Fast Title
If bolNoSong = True Then GoTo NoSong
idx = Me.Label7.Tag
strFile = aryFT(idx + 1, 2)
Case 64 'SHIFT+2 = Fast Line
If bolNoSong = True Then GoTo NoSong
idx = Me.Label9.Tag
strFile = aryFL(idx + 1, 2)
Case 35 'SHIFT+3 = Fast Chorus
If bolNoSong = True Then GoTo NoSong
idx = Me.Label8.Tag
strFile = aryFC(idx + 1, 2)
Case 36 'SHIFT+4 = Slow Title
If bolNoSong = True Then GoTo NoSong
idx = Me.Label10.Tag
strFile = aryST(idx + 1, 2)
Case 37 'SHIFT+5 = Slow Line
If bolNoSong = True Then GoTo NoSong
idx = Me.Label12.Tag
strFile = arySL(idx + 1, 2)
Case 94 'SHIFT+6 = Slow Chorus
If bolNoSong = True Then GoTo NoSong
idx = Me.Label11.Tag
strFile = arySC(idx + 1, 2)
Case 49 '1 = Fast List #1
strFile = aryFT(Me.Combo7.ListIndex + 1, 2)
Case 50 '2 = Fast List #2
strFile = aryFT(Me.Combo8.ListIndex + 1, 2)
Case 51 '3 = Fast List #3
strFile = aryFT(Me.Combo9.ListIndex + 1, 2)
Case 52 '4 = Offering
strFile = aryFT(Me.Combo10.ListIndex + 1, 2)
Case 53 '5 = Slow List #1
strFile = aryST(Me.Combo11.ListIndex + 1, 2)
Case 54 '6 = Slow List #2
strFile = aryST(Me.Combo12.ListIndex + 1, 2)
Case 55 '7 = Slow List #3
strFile = aryST(Me.Combo13.ListIndex + 1, 2)
Case 56 '8 = Slow List #4
strFile = aryST(Me.Combo14.ListIndex + 1, 2)
End Select
SongClosed:
KeyAscii = 0
Me.Text1.Text = ""
'Stop
'If Word app is gone, reset app object
Err.Clear
On Error Resume Next
Dim tstAppName As String
tstAppName = appWd.Name
On Error GoTo 0
If tstAppName = "" Then
Set appWd = New Word.Application
End If
tstAppName = ""
If bolSongCls = True Then
bolSongCls = False
If bolTwoMon = True Then
SearchMe.SetFocus
SearchMe.Text1.SetFocus
End If
GoTo NoSong
End If
'Stop
If strFile <> "" Then
cntSongs = cntSongs + 1
arySongs(cntSongs) = strFile
strFile = Chr(34) & strFile & Chr(34)
Set doc = appWd.Documents.Open(FileName:=strFile, Visible:=True)
'doc.AttachedTemplate = Chr(34) & "C:\Documents and Settings\Ed\My Documents\FindSongs\SongsTempl.dot" & Chr(34)
appWd.ActiveWindow.WindowState = wdWindowStateMaximize
appWd.ActiveWindow.View = wdPrintView
'''appWd.ActiveWindow.View.Zoom.Percentage = 92
'''appWd.ActiveWindow.View.Zoom.Percentage = 130
doc.ActiveWindow.ActivePane _
.Zooms(wdPrintView).PageFit = wdPageFitFullPage
bolFirstLet = True
Else
'MsgBox "No file"
End If
If bolTwoMon = False Then
'Set form to go back
frmTop = SearchMe.Top
frmLeft = SearchMe.Left
SearchMe.Top = 3
SearchMe.Left = 3
SearchMe.Height = 1
SearchMe.Width = 5000
SearchMe.Caption = "Close song by typing 0 (zero)."
End If
Timer1.Enabled = True
Timer1.Interval = 600
If strFile <> "" Then
On Error Resume Next
appWd.Visible = True
AppActivate appWd.Caption
appWd.Windows(1).Activate
On Error GoTo 0
appWd.Windows(1).View.TableGridlines = False
appWd.Windows(1).DisplayRulers = False
appWd.Windows(1).View.ShowAll = False
doc.ShowGrammaticalErrors = False
doc.ShowSpellingErrors = False
appWd.Windows(1).SmallScroll Down:=3
'If bolTwoMon = True Then
SearchMe.SetFocus
SearchMe.Text1.SetFocus
'End If
End If
NoSong:
bolNoSong = False
End Sub
Private Sub Timer1_Timer()
Dim tstDocName As String
' Check to see if a Word doc exists
On Error Resume Next
Set doc = appWd.Documents(1)
tstDocName = doc.Name
'If no Word doc, restore form
If Err.Number <> 0 Then
Timer1.Enabled = False
Set doc = Nothing
'Bring app to front
appWd.Visible = False
SearchMe.Top = frmTop
SearchMe.Left = frmLeft
SearchMe.Height = 12075
SearchMe.Width = 10980
SearchMe.Caption = "Search Song List"
'''SearchMe.Visible = True
SearchMe.SetFocus
SearchMe.Text1.SetFocus
Else
'If a Word doc exists, ensure form has focus
Call SetWindowPos(MyHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE)
Call SetActiveWindow(MyHwnd)
'SearchMe.SetFocus
'AppActivate ("FindMySong")
If bolTwoMon = False Then _
doc.Windows(1).Activate
End If
On Error GoTo 0
End Sub