Executing Javascript from IE

Omega01

New Member
Joined
Nov 9, 2013
Messages
1
Hey, I need some expert advice since I am pretty stump. I am trying to log on to Wells Fargo https://wellsoffice.wellsfargo.com/ceoportal/signon/index.jsp, so I can automatically download data directly into my Excel Workbook. The problem is Wells Fargo uses Javascript for its form and I have no idea how to execute the necessary function to submit the form. Please see below for the VBA code and the javascript source file. If someone could assist me with this, I would be very thankful.



Option Explicit

Sub Test()

Const cURL = "https://wellsoffice.wellsfargo.com/ceoportal/signon/index.jsp"
Const cCompany = "xxxxx" 'REPLACE XXXX WITH YOUR USER NAME
Const cUsername = "yyyyy" 'REPLACE XXXX WITH YOUR USER NAME
Const cPassword = "ssss" 'REPLACE YYYY WITH YOUR PASSWORD

Dim IE As InternetExplorer
Dim doc As HTMLDocument
Dim LoginForm As HTMLFormElement
Dim UserNameInputBox As HTMLInputElement
Dim PasswordInputBox As HTMLInputElement
Dim SignInButton As HTMLInputElement
Dim HTMLelement As IHTMLElement

Set IE = New InternetExplorer

IE.Visible = True
IE.Navigate cURL

'Wait for initial page to load

Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop

Set doc = IE.Document

'Get the only form on the page

Set LoginForm = doc.forms(0)

'Get the User Name textbox and populate it

Set UserNameInputBox = LoginForm.elements("COMPANY")
UserNameInputBox.Value = cCompany

'Get the User Name textbox and populate it


Set UserNameInputBox = LoginForm.elements("WFUID")
UserNameInputBox.Value = cUsername

'Get the password textbox and populate it


Set PasswordInputBox = LoginForm.elements("Password")
PasswordInputBox.Value = cPassword

'Get the form input button and click it

IE.Document.all.Item
Call IE.Document.parentWindow.execScript("submitform()", "JavaScript")


End Sub



/*global WF,alert,YAHOO */
/**
* Signon Page Helper - Arno's!.
*/
WF.onWRIAReady({ modules: ["WF.Component","WF.widget.SimpleButton", "WF.widget.WaitMessage"] }, function(){
var _portalPath = "/ceoportal/", _formAction = "",
_cookieUser = "CEOUSER", _cookieCompany = "CEOCOMPANY",
wf_cfmHelper, wue = WF.util.Event,
wf_spinner;

WF.Class.defineSingletonClass("CEOP.SignonHelper", WF.Component, null, function(CLSDEF) {
/*
* Private methods
*/
var ceoLoadingPage = function(pageName) {
wf_spinner.show();

//sets the window width and height
// var STATUS_WINDOW_NAME = "statusWin";
// var LOADING_URL = _portalPath + "signon/loader.jsp";

// var window_width = 440;
// var window_height = 100;
// var screen_balance_w = ((screen.width)-(window_width))/2;
// var screen_balance_h = ((screen.height)-(window_height))/2;
// var set_top = screen_balance_h;
// var set_left = screen_balance_w;

// var win = ************(LOADING_URL,STATUS_WINDOW_NAME,'width=' + window_width +
// ',height=' + window_height + ',top=' + set_top + ',left=' + set_left + '');
// win.focus();
return true;
};

var checkFieldEmpty = function(fieldId, fieldName) {
var fieldEl = WF.$(fieldId);
if (fieldEl.value === "") {
fieldEl.focus();
alert("Please make sure the " + fieldName + " field was properly completed.");
return false;
}
return true;
};

var validateForm = function(event) {
// Fields cannot be empty
if (checkFieldEmpty("comp_id", "Company ID") === false) {
return false;
}
if (checkFieldEmpty("user_id", "User ID") === false) {
return false;
}
if (checkFieldEmpty("password", "Password") === false) {
return false;
}
return true;
};

var cancelSubmit = function(event) {
try { // preventing IE to crash
wue.stopEvent(event);
return false;
} catch(ex) {}
return false;
};

var submitForm = function(event) {
if (validateForm(event) === true) {
// load 'please wait'
ceoLoadingPage();

WF.util.Cookie.getInst(_cookieUser).setValue(document.formlogin.WFUID.value.wf_trim().toUpperCase());
WF.util.Cookie.getInst(_cookieCompany).setValue(document.formlogin.COMPANY.value.wf_trim().toUpperCase());
document.formlogin.PASSWORD.value = document.formlogin.PASSWORD.value.toUpperCase();
document.formlogin.COMPANY.value = document.formlogin.COMPANY.value.wf_trim().toUpperCase();
document.formlogin.WFUID.value = document.formlogin.WFUID.value.wf_trim().toUpperCase();
document.formlogin.action = _formAction;
// call CFMs
document.forms[0].pm_fp.value = wf_cfmHelper.pmfp();
document.forms[0].fortyone.value = wf_cfmHelper.fortyone();

document.formlogin.submit();
return false;
} else {
return cancelSubmit(event);
}
};

var validateKeyAndSubmit = function(event) {
if ( wue.getCharCode(event) === YAHOO.util.KeyListener.KEY.ENTER ) {
submitForm(event);
}
};

/*
* Class definition
*/
CLSDEF.addInstanceMethods({
init: function() {
// Inherit from Component
this.wf_super();
},

signonSimpleButton: function( params ) {
return WF.widget.SimpleButton.getInst({
container: params.container,
callback: params.callback,
text: params.text,
style: params.style,
disabled: params.disabled,
title: ""
});
},
expireCookie: function(name) {
var cookie = WF.util.Cookie.getInst(name);
if ( cookie.exists() ) {
cookie.expire();
}
},

initComponent: function(json) {
var data = WF.decode(json, null);
if (data) {
_portalPath = data.portalPath || "/ceoportal/";
_formAction = data.formAction || "";
_cookieUser = data.cookieUser || "CEOUSER";
_cookieCompany = data.cookieCompany || "CEOCOMPANY";
}

/* Custom initialization here */
// prepare the spinner for future use
wf_spinner = WF.widget.WaitMessage.getInst({
style: WF.widget.WaitMessage.WAIT_SPINNER,
line1: "Authentication in progress",
visible: false
});

// Reset the window.name just in case
window.name = "ceo_login";

// add skin-ceo class to display simple button
WF.getEl(document.body).addClass('skin-ceo');

var params = { "text" : "Sign On",
"disabled" : false,
"callback" : function() {
submitForm(this);
},
"style" : WF.widget.SimpleButton.STYLES.BLOCK,
"container" : "signOnButton"};
this.signonSimpleButton(params);

// Check if we are coming from session timeout
var str = WF.util.URL.getInst().getParamValue("RC");
if ( str && str === "811" ) {
var img = new Image();
img.src = ****************.protocol + "//" + ****************.host +
"/login/logoff.gif?ts=" + Math.random();
this.expireCookie("SMSESSION");
}
// load the CFM helper
wf_cfmHelper = WF.CFM.helper;

/* Assign action on form submit */
var signForm = WF.getEl("SignOnForm");

if ( signForm ) {
signForm.on("keypress", function(event) {
validateKeyAndSubmit(event);
});
}

/* Display warning for XHR if needed */
if (WF.env.isXHRenabled === false) {
WF.getEl("warning_xhr_disabled").show();
}

/* Update a cookie with the value of XHR */
var cookie = WF.util.Cookie.getInst("CEOP_JAR");
cookie.setSubValue("isXHRenabled", WF.env.isXHRenabled ? "true" : "false");

/* Only show Ad panels that actually exist */
[ WF.getEl("right_panel_top"),
WF.getEl("right_panel_bottom")].wf_each(function(item) {
if (item) {
item.show();
}
});

/* update the style for the session expiration if present */
var timeout = WF.$$(".timeout", document, true, true);
if (timeout) {
var parent = timeout.parent();
parent.removeClass("highPriorityErrorSignon");
parent.addClass("sessionTimeoutSignon");
}

[ WF.getEl("signonContent3-1"),
WF.getEl("signonContent3-2"),
WF.getEl("signonContent3-3")].wf_each(function(item) {
if (item) {
item.show().setVisibility(true);
}
});

try {
WF.$("comp_id").focus();
} catch (ex) {}

return false;
}
}); // addInstanceMethods
}); // defineSingletonClass
}); // onWRIAReady
 
Last edited:

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

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