Help removing "sendkeys"

IvoOvermars

New Member
Joined
Aug 6, 2010
Messages
12
Hello,

I had to enter 3 x 1800 sudentnumbers in a webbased application (magister) by hand. I ended up writing this code and the pressure is off. Next year however the same will have to be done.

And I'm trying to optimise this. I'm using the SendKeys command and I would like to replace this with some other code. I have no clue how to do that.


VBA Code:
Sub leerlinginvoer()
'

    ActiveCell.Copy
    Application.Wait (Now() + TimeValue("00:00:01"))
    SendKeys "%{TAB}"
    Application.Wait (Now() + TimeValue("00:00:01"))
'clear input field
    SendKeys "{BACKSPACE}"
    SendKeys "{BACKSPACE}"
    SendKeys "{BACKSPACE}"
    SendKeys "{BACKSPACE}"
    SendKeys "{BACKSPACE}"
    SendKeys "{BACKSPACE}"

   
    SendKeys "^{v}"
    Application.Wait (Now() + TimeValue("00:00:01"))
    SendKeys "{DOWN}"

    SendKeys "{enter}"
    Application.Wait (Now() + TimeValue("00:00:01"))


Do Until ActiveCell = NullString
    'nieuwe cell
   
    ActiveCell.Copy
    SendKeys "%{TAB}"
    Application.Wait (Now() + TimeValue("00:00:01"))
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Copy
    Application.Wait (Now() + TimeValue("00:00:01"))
    SendKeys "%{TAB}"
    Application.Wait (Now() + TimeValue("00:00:01"))
    SendKeys "{BACKSPACE}"
    SendKeys "{BACKSPACE}"
    SendKeys "{BACKSPACE}"
    SendKeys "{BACKSPACE}"
    SendKeys "{BACKSPACE}"
    SendKeys "{BACKSPACE}"

    SendKeys "^{v}"
    Application.Wait (Now() + TimeValue("00:00:01"))
    SendKeys "{DOWN}"

    SendKeys "{enter}"
    Application.Wait (Now() + TimeValue("00:00:01"))
   
Loop


MsgBox "Next"
  
End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
2,147
If you could share the url of the web service that you use, and we could get access to the same service as you do, we could develop a way for interacting with the web page; for example as we did in this recent discussion: extract info from website.

But I suspect this is impossible...
You could try to attach the html source code of the page you need to interact with, along with a screenshot with the layout of the interaction mask, but it'll be difficult to get a result without access to the page, as these are "try and error" developments.

A simple speed advance could be obtained by using Sleep to schedule waiting states for few millisecs to hours; I guess that very often a Sleep(100) (wait 0.1 sec) can replace your many Wait 1 sec

To use the Sleep function you have first to declare it on top of the vba Module:
VBA Code:
#If VBA7 Then
    Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
#Else
    Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
#End If
Then you may replace your several Application.Wait (Now() + TimeValue("00:00:01")) with
VBA Code:
Sleep (100)        '100=100 msec; adjust this delay to cope with the situation

Bye
 

IvoOvermars

New Member
Joined
Aug 6, 2010
Messages
12


I have to enter the numbers in the "Deelnemers" field. A dropdownmenu will appear and Ihave to select the student I want to select. My number is complete so I never have more then one match.

afspraak inplannen 2.png
 

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
2,147
You passed us the url of the page where we could log-in, if only we were Corderius College members...
So, either give us some valid credentials to login, OR you should copy here the "html source code" of the page that you interact with after the login; normally you get this by right click on the web page, the choose "Display source code" or something similar.
Also try loading a high resolution image (we need to read the headers of the filelds, at least)

Bye
 

Watch MrExcel Video

Forum statistics

Threads
1,129,396
Messages
5,636,060
Members
416,896
Latest member
Hozier

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
Top