Populate on Internet Explorer Windows Already Open Using Excel VBA and sendkey "ENTER"

Daddydude

New Member
Joined
Oct 29, 2020
Messages
6
Office Version
  1. 2013
Platform
  1. Windows
Hi all,

I have a web form page to populate using Excel VBA. My data is in 4 columns and has over 2000 lines. For each line, I need to send the values of the first 3 columns to specific fields, then the "ENTER" key must be pressed, the macro will require to wait for the webpage to update, then send the value of the 4th column and finalize with another "ENTER" key pressed. Then it needs to move on to the second line of data and repeat the process till the end of spreadsheet data.

This web form doesn't have any buttons to click, it must be an "ENTER" key pressed.

I found this bit of code posted by Domenic back in 2018 and it works perfectly for what I need to do, but I have trouble figuring out how to send the "ENTER" key to the webpage and wait.
Can someone help me out ?
Thanks in advance.

Here is the code:

Option Explicit
Sub Login()

Dim oShell As Object
Dim oShellWindows As Object
Dim oShellWindow As Object

Set oShell = CreateObject("Shell.Application")
Set oShellWindows = oShell.Windows

For Each oShellWindow In oShellWindows
If oShellWindow.Name = "Internet Explorer" Then
If oShellWindow.Document.Title = "identificazione" Then
With oShellWindow.Document
.all("entry.402896772").Value = ThisWorkbook.Sheets("Foglio1").Range("D2").Value
.all("entry.249387921").Value = ThisWorkbook.Sheets("Foglio1").Range("E2").Value
'etc
'
'
End With
Exit For
End If
End If
Next oShellWindow

Set oShell = Nothing
Set oShellWindows = Nothing
Set oShellWindow = Nothing

End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
IF it helps, I found this function in javascript imbedded into the webpage:

function FKeyAction(strMessage, strSubmitValue) {
// If help page is displayed, FKeys are not allowed
if ($.isHelpDisplayed) {
return;
}
if (!$.alreadySubmitted) {
// Check if the function key is activated
if (strMessage == "Submitting" ||
getObjectById("FunctionKeys", "INPUT").value.indexOf(strMessage) > -1) {
// If so submit the data
$.alreadySubmitted = true;
window.status = strMessage;
getObjectById("SubmitAction", "INPUT").value = strSubmitValue;
// Set the timestamp
var now = new Date();
getObjectById("RoundTripTimestamp", "INPUT").value = now.getTime();
var isValidated = processPrePostValidation();
if (isValidated) {
VerifyNowEmptyFocuElements();
PopulateNumericFields();

document.forms[0].submit();
} else {
$.alreadySubmitted = false;
window.status = "";
}
}
else {
// We don't want anything to happen when the function keys are disabled
window.status = "";
}
}
// Cancel the event since we are either submitting already or we do not want to do anything
cancelEvent();
}
 
Upvote 0
13: {
name: 'submit',
callback: DoNewline,
ctrlCallback: DoNewline,
shiftCallback: DoSubmit,
NumPadEnter: DoSubmit


function DoSubmit() {
CancelQuitEvent();
// If help page is displayed, submission is not allowed
if ($.isHelpDisplayed) {
return;
}
// Submit the form.
FKeyAction("Submitting", "0");
 
Upvote 0
And also this...
13: { name: 'submit', callback: DoNewline, ctrlCallback: DoNewline, shiftCallback: DoSubmit, NumPadEnter: DoSubmit function DoSubmit() { CancelQuitEvent(); // If help page is displayed, submission is not allowed if ($.isHelpDisplayed) { return; } // Submit the form. FKeyAction("Submitting", "0");
 
Upvote 0
You can delete this thread, i found the answer to my issues. Thanks
 
Upvote 0

Forum statistics

Threads
1,223,892
Messages
6,175,236
Members
452,621
Latest member
Laura_PinksBTHFT

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