我正在使用HostExplorer主机终端仿真器。我的VBA知识是基于将我在网上找到的信息拼凑在一起来制作其他宏。将Excel文本输入到HostExplorer主机模拟器屏幕上的字段
我正在制作一个宏,在大型机中输入发票,在几个屏幕之间移动,输入将生成链接的信息,然后使用该链接将文件保存到我的计算机上的预定文件夹。
我被困在输入信息部分。导航到最后一个屏幕后,我需要将文本输入到大型机的特定字段中。
我知道如何识别屏幕上的位置并使用它来创建变量。
我该怎么做,在屏幕上的特定位置输入一个字符串保存在一个变量(或只是一个随机字母)?
Sub MiscFileDownload()
Dim HostExplorer As Object
Dim MyHost As Object
Dim Rc As Integer
On Error GoTo GenericErrorHandler
Set HostExplorer = CreateObject("HostExplorer") ' Initialize HostExplorer Object
Set MyHost = HostExplorer.HostFromProfile("*****") ' Set object for the desired session
If MyHost Is Nothing Then GoTo NoSession
Dim ColALastRow As Long
ColALastRow = Worksheets(1).Columns("A:A").End(xlDown).Row
Dim Pro As String
Dim MiscTest As String
Dim iPSUpdateTimeout
'enter pro then F2 and F9
For i = 2 To ColALastRow
Pro = Worksheets(1).Cells(i, 1).Value
Rc = MyHost.Keys(Pro)
iPSUpdateTimeout = 60
MyHost.RunCmd ("Enter")
Rc = MyHost.WaitPSUpdated(iPSUpdateTimeout, True)
If Rc <> 0 Then GoTo OnWaitPSUpdatedTimeout
iPSUpdateTimeout = 60
MyHost.RunCmd ("PF2")
Rc = MyHost.WaitPSUpdated(iPSUpdateTimeout, True)
If Rc <> 0 Then GoTo OnWaitPSUpdatedTimeout
iPSUpdateTimeout = 60
MyHost.RunCmd ("PF9")
Rc = MyHost.WaitPSUpdated(iPSUpdateTimeout, True)
If Rc <> 0 Then GoTo OnWaitPSUpdatedTimeout
MiscTest = Mid(MyHost.Text, 1466, [3])
If MiscTest = "YES" Then 'test for Misc if true move to next screen
Rc = MyHost.Keys("v")
Rc = MyHost.WaitPSUpdated(iPSUpdateTimeout, True)
If Rc <> 0 Then GoTo OnWaitPSUpdatedTimeout
MyHost.RunCmd ("Tab")
Rc = MyHost.WaitPSUpdated(iPSUpdateTimeout, True)
If Rc <> 0 Then GoTo OnWaitPSUpdatedTimeout
Rc = MyHost.Keys("v")
Rc = MyHost.WaitPSUpdated(iPSUpdateTimeout, True)
If Rc <> 0 Then GoTo OnWaitPSUpdatedTimeout
MyHost.RunCmd ("Tab")
Rc = MyHost.WaitPSUpdated(iPSUpdateTimeout, True)
If Rc <> 0 Then GoTo OnWaitPSUpdatedTimeout
Else
MyHost.RunCmd ("PF1")
Rc = MyHost.WaitPSUpdated(iPSUpdateTimeout, True)
If Rc <> 0 Then GoTo OnWaitPSUpdatedTimeout
MyHost.RunCmd ("PF1")
Rc = MyHost.WaitPSUpdated(iPSUpdateTimeout, True)
If Rc <> 0 Then GoTo OnWaitPSUpdatedTimeout
GoTo NextIteration
End If
NextIteration:
Next i
Exit Sub
你只是想输入文字吗?我不确定你的主机是什么,但它看起来像你可以使用key()方法输入!喜欢:MyHost.Keys(“thevalueyouwanttoType”) –
MyHost.Keys(“thevalueyouwanttoType”)的作品来输入字符串,但我需要知道如何将它输入到一个特定的位置,如果这是有道理的? 例如,MiscTest = Mid(MyHost.Text,1466,[3])会将该变量设置为等于从“位置?”开始的字符串。 1466在我的hostexplorer。如何在使用Myhost.keys之前导航到特定位置? – user2996913
http://vbcity.com/forums/t/42741.aspx这可能会有所帮助。 –