I have no experience with If Statements. But I think I need one to accomplish this task unless there is another way to do it.
I have a specific screen that has "Morbiles" which is a > that is underlined. Placing the cursor on it and typing "M" and press enter brings up another screen that I have to copy to a file then go back and do the next one. Problem is this screen could have no Morbiles or up to 6 morbiles. Hence the problem. After all the screens are copied to the file the macro sends the file to print.
Here is that part of the code.
Shell "Notepad c:\My Documents\Print.txt"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%{tab}"
‘This section is a continuation from coping several other screens until I get to this screen.
Sess0.Screen.Sendkeys("<PF10>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.MoveTo 10,68 'Moves to the First Morbile “ > “
‘Morbiles could exist on 11,68, 12,68, 13,68 thru 16 or none at all.’
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("M<Enter>") ‘brings up another screen
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
Set MyScreen = Sess0.Screen
MyScreen.SelectAll
MyScreen.Copy
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<PF3>") ‘back to the morbile screen
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
AppActivate "Print.txt - Notepad"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "{Enter 8}%EP" ‘-----------------------Paste in Notepad
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%{tab}" 'back to attachmate
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
‘If Morbile exists go to each morbile “m <Enter>” and copy each page to Print.txt.
‘Then print the file.
' Prints the File
AppActivate "Print.txt - Notepad"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%FP"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "{Tab}"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "-"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%P"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%FX"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "N"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
System.TimeoutValue = OldSystemTimeout
End sub
I have a specific screen that has "Morbiles" which is a > that is underlined. Placing the cursor on it and typing "M" and press enter brings up another screen that I have to copy to a file then go back and do the next one. Problem is this screen could have no Morbiles or up to 6 morbiles. Hence the problem. After all the screens are copied to the file the macro sends the file to print.
Here is that part of the code.
Shell "Notepad c:\My Documents\Print.txt"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%{tab}"
‘This section is a continuation from coping several other screens until I get to this screen.
Sess0.Screen.Sendkeys("<PF10>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.MoveTo 10,68 'Moves to the First Morbile “ > “
‘Morbiles could exist on 11,68, 12,68, 13,68 thru 16 or none at all.’
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("M<Enter>") ‘brings up another screen
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
Set MyScreen = Sess0.Screen
MyScreen.SelectAll
MyScreen.Copy
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<PF3>") ‘back to the morbile screen
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
AppActivate "Print.txt - Notepad"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "{Enter 8}%EP" ‘-----------------------Paste in Notepad
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%{tab}" 'back to attachmate
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
‘If Morbile exists go to each morbile “m <Enter>” and copy each page to Print.txt.
‘Then print the file.
' Prints the File
AppActivate "Print.txt - Notepad"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%FP"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "{Tab}"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "-"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%P"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%FX"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "N"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
System.TimeoutValue = OldSystemTimeout
End sub