Hi everyone.
Would appreciate your assistance if possible.
I am using sendkeys to mitigate a data entry process. I found the code below and had some success with being able to send keys.
I have data in Column A, and some of the values are static whilst others are filled dynamically.
How do I loop the below code so that I can basically Sendkey (a1), sleep 500, Sendkey (a2), sleep 500, Sendkey (a3) etc until there is no more. (column downwards one by one only)
Is it a combination of using counta to find the total number of rows
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]John[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][tab][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Doe[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][tab][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]13/11/2018[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][enter][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][tab][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]etc...[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Would appreciate your assistance if possible.
I am using sendkeys to mitigate a data entry process. I found the code below and had some success with being able to send keys.
I have data in Column A, and some of the values are static whilst others are filled dynamically.
How do I loop the below code so that I can basically Sendkey (a1), sleep 500, Sendkey (a2), sleep 500, Sendkey (a3) etc until there is no more. (column downwards one by one only)
Is it a combination of using counta to find the total number of rows
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]John[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][tab][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Doe[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][tab][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]13/11/2018[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][enter][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][tab][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]etc...[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Code:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub FINAL()
Const IntHostWaitMs As Integer = 1000
Dim ResultStr As String, i As Integer
Dim autECLPSObj As Object
Dim autCon As Object
Dim autECLOIAObj As Object
Dim Find_Object_A
Set autCon = CreateObject("PCOMM.autECLConnMgr")
autCon.autECLConnList.Refresh
Set Find_Object_A = autCon.autECLConnList.findconnectionbyname("A")
If Find_Object_A Is Nothing Then
MsgBox "Start Host"
GoTo ExitProcedure
End If
Set autECLPSObj = CreateObject("PCOMM.autECLPS")
Set autECLOIAObj = CreateObject("PCOMM.autECLOIA")
autECLOIAObj.SetConnectionByName ("A")
' Initialize the connection
autECLPSObj.SetConnectionByHandle (autCon.autECLConnList(1).Handle)
'Just some commands to host session
autECLPSObj.SendKeys Range("A1")
autECLPSObj.SendKeys Range("A2")
autECLPSObj.SendKeys Range("A3")
autECLPSObj.SendKeys Range("A4")
Sleep 500
autECLOIAObj.WaitForInputReady IntHostWaitMs
ResultStr = autECLPSObj.GetText(8, 18, 20)
ExitProcedure:
Set autCon = Nothing
Set Find_Object_A = Nothing
Set autECLPSObj = Nothing
Set autECLOIAObj = Nothing
Exit Sub
Errorhandler:
MsgBox "error occured." & _
vbCrLf & "ErrorNo: " & Err & _
vbCrLf & "LineNo: " & Err.Line & _
vbCrLf & "Errormsg:" & _
vbCrLf & Err.Description, vbCritical, "Error"
Resume ExitProcedure
End Sub