VBA to open website and logon with username & password

BrazenMore

New Member
Joined
Apr 14, 2010
Messages
9
Hi
I have the following code which opens a webpage and goes to the username & password fields and logons. However for so strange reason sometimes when the sendkeys sends the username or password it types on the screen incorrectly i.e. the username is brazenmore and sometimes this appears as bbrazenmore or bbrazzzenmore. The code works some of the time any ideas why this happens?

Sub internetlogon()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
'Go to this Web Page!
IE.Navigate "enter web page here"
'Check for good connection to web page loop!
Do
If IE.ReadyState = 4 Then
IE.Visible = False
Exit Do
Else
DoEvents
End If
Loop
'Wait for window to open!
Application.Wait (Now + TimeValue("0:00:01"))
IE.Visible = True
'Send logon information
SendKeys "brazenmore", True
SendKeys "{TAB}", True
SendKeys "brazenmore", True
 
Here is the javascript logon info I see the username and the value so how would I enter that into the vba code?

Code:
'div class="logon_table"								'
					
'		div id="userName" class="logon_input">			 
'			label class="logon_input_label" for="usernameTextEdit" tabIndex=-1>
'				User Name:
'			/label>				 
'				
'					
'					
'					input type="text" name="username" value="270010437" class="inputTextBox logonTextBox" id="usernameTextEdit">	
'					
'			
'		/div>
'		div id="password" class="logon_input">			
'			label class="logon_input_label" for="passwordTextEdit" tabIndex=-1>
'				Password:
'			/label>			
'			input type="password" name="password" value="" class="inputTextBox logonTextBox" id="passwordTextEdit">
'		/div>
'		
			div id="authentication" class="logon_input">
'				
'				  label class="logon_input_label" for="authenticationSelectBox" tabIndex="-1" '*******="businessobjects.webutil.accessibility.setFocusOnElement('authenticationSelectBox'); return false;">
'					Authentication:
'				  label>
'				
'				  select name="authType" class="logonSelectBox" id="authenticationSelectBox"><OPTION value='secEnterprise'>
'										Enterprise
'								
'													
'								
'									OPTION selected value='secLDAP'>'
'										LDAP
'								
'								
'								
'							
'								
'								
'								
'									OPTION value='secWinAD'>
'										Windows AD</select>
'			/div>
'										
'/div
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
:confused: If i have one website example https://www.xyz.com
When i open that website i can see hyper links. and if i want perticular information from sorce file then how can i get that. Below is sorce..
I want A HREF= " person ? id =
from that sorce<a href="person?id=<font color=" #008000"="">
 
Last edited:
Upvote 0
<BR>India
<TR><TD VALIGN=TOP>Building Code <TD>WPR-41-IN
<TR><TD VALIGN=TOP>Manager <TD><A HREF="person?id=1234567" TARGET="main_right">Milind Kale (MR)</A> (<A HREF="https://xyz.abc.atc/Pages/index.aspx" TARGET=_top>BT Global Services</A>, <A HREF="staff?id=1234567" TARGET="main_right">JSSF1</A>)
<TR><TD COLSPAN="3">Above information is made available from the BT People system.<BR>
 
Upvote 0
<BR>India
<TR><TD VALIGN=TOP>Building Code <TD>WPR-41-IN
<TR><TD VALIGN=TOP>Manager <TD><A HREF="person?id=1234567" TARGET="main_right">Milind Kale (MR)</A> (<A HREF="https://xyz.abc.atc/Pages/index.aspx" TARGET=_top>BT Global Services</A>, <A HREF="staff?id=1234567" TARGET="main_right">JSSF1</A>)
<TR><TD COLSPAN="3">Above information is made available from the BT People system.<BR>

Milu,

Can you fix your post?

All I see is a video.

Weird now I can see your post. Earlier I saw a video.

Kurt
 
Upvote 0
I am trying to get Norrie's code to work.

I have the following javascript code:

Code:
<input type="hidden" name="qryStr" value="">
 
<input type="hidden" name="cmsVisible" value="false">
 
<input type="hidden" name="cms" value="rhuprdbibo01.Rexelusa.com:6400">
 
<input type="hidden" name="authenticationVisible" value="true">
 
 
<input type="hidden" name="isFromLogonPage" value="true">
<input type="hidden" name="appName" value="SAP BusinessObjects InfoView">
<input type="hidden" name="prodName" value="BusinessObjects">
<input type="hidden" name="sessionCookie" value="true">
<input type="hidden" name="backUrl" value="/listing/main.do">
<input type="hidden" name="backUrlParents" value="1">
<input type="hidden" name="backContext" value="/InfoViewApp">
<input type="hidden" name="persistCookies" value="true">
<input type="hidden" name="useLogonToken" value="true">
<input type="hidden" name="service" value="/InfoViewApp/common/appService.do">
<input type="hidden" name="appKind" value="InfoView">
<input type="hidden" name="loc" value="en">
<input type="hidden" name="reportedIP" value="">
<input type="hidden" name="reportedHostName" value="">
 
******** type="text/javascript" src="../../../PlatformServices/js/accessibility_util.js">*********>
******** type="text/javascript"> 
	function logIPAndHostName()
	{
		var hostaddress = "";
		var hostname = "";
		try {
			hostname = top.location.host; //This works in IE.
			var localhost = new java.net.InetAddress.getLocalHost(); //This only works in FireFox with Java enabled.
			hostaddress = localhost.getHostAddress();
			hostname = localhost.getHostName();
		} catch(e) {
            // do nothing
		}
		document.forms[0].reportedIP.value = hostaddress;
		document.forms[0].reportedHostName.value = hostname;
		return true;
	}
*********>
 
 
 
 
<div class="logon_table">								
					
		<div id="userName" class="logon_input">			 
			<label class="logon_input_label" for="usernameTextEdit" tabIndex=-1>
				User Name:
			</label>				 
				
					
					
					<input type="text" name="username" value="270010437" class="inputTextBox logonTextBox" id="usernameTextEdit">	
					
			
		</div>
		<div id="password" class="logon_input">			
			<label class="logon_input_label" for="passwordTextEdit" tabIndex=-1>
				Password:
			</label>			
			<input type="password" name="password" value="" class="inputTextBox logonTextBox" id="passwordTextEdit">
		</div>
		
			<div id="authentication" class="logon_input">
				
				  <label class="logon_input_label" for="authenticationSelectBox" tabIndex="-1" *******="businessobjects.webutil.accessibility.setFocusOnElement('authenticationSelectBox'); return false;">
					Authentication:
				  </label>
				
				  <select name="authType" class="logonSelectBox" id="authenticationSelectBox"><OPTION value='secEnterprise'>
										Enterprise
								
								
							
								
								
									<OPTION selected value='secLDAP'>
										LDAP
								
								
								
							
								
								
								
									<OPTION value='secWinAD'>
										Windows AD</select>
			</div>
										
</div>
 
 
	
<div id="buttonTable" class="logon_button_pos">	 	 	
		<input type="submit" class="logon_button logon_button_no_hover" value='Log On'
		*******="logIPAndHostName();" ***********="this.className='logon_button logon_button_hover';"
		**********="this.className='logon_button logon_button_no_hover';" />		 	 	
</div>
 
 
 
</form>
							
					
				
			</div>			   
         </div>
    </div>
</body>
</html>
 
[code]

This is my VBA code:

[code]
Sub Test2()
    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.application")
    With IE
        .Visible = True
        '.navigate ("http://auros.co.uk/default.aspx")
        '.navigate ("http://glenigan-cms.auros.co.uk")
        .navigate ("http://rhuprdbibo01.rexelusa.com:8080/InfoViewApp/logon.jsp")
        While .Busy Or .readyState <> 4: DoEvents: Wend
    .Document.getElementById("logon_input_label_password").Focus
    .Document.getElementById("logon_input_label_password").Value = ""
    .Document.all("Template_GLE_Login_LoginView1_login_LoginButton").Click
        While .Busy Or .readyState <> 4: DoEvents: Wend
        Debug.Print .LocationURL
    End With
End Sub
[code]

I believe what I am looking for is here in this section of the above javascript code.

[code]
</div>
		<div id="password" class="logon_input">			
			<label class="logon_input_label" for="passwordTextEdit" tabIndex=-1>
				Password:
			</label>			
			<input type="password" name="password" value="" class="inputTextBox logonTextBox" id="passwordTextEdit">
		</div>
		
			<div id="authentication" class="logon_input">
				
				  <label class="logon_input_label" for="authenticationSelectBox" tabIndex="-1" *******="businessobjects.webutil.accessibility.setFocusOnElement('authenticationSelectBox'); return false;">
					Authentication:
				  </label>
				
				  <select name="authType" class="logonSelectBox" id="authenticationSelectBox"><OPTION value='secEnterprise'>
										Enterprise

Can someone show me how to code this correctly? :-)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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