Looping Sendkeys One by One, pause in between.

meepotab

New Member
Joined
Nov 13, 2018
Messages
1
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]





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

 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Similar threads

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top