Vba Assistance Required.

needhelp2

New member
Joined
Jul 4, 2011
Messages
2
Reaction score
0
Points
0
Hi,

I am trying to login in to Google from excel 2003,when ever i click on button it give me login forum to enter id and password manually,After that I have to click on submit button and IE open for google and login successfully .But what i want that i dont want to enter and and password manually,I want that it copy to login form from range a1,a2 for id and password respectively.

Is there any way i fix my range,where from or where i place my login and password,
On pressing button it copy id and password and then login?

Kindly check attached file,Please give me a little assistance.


Best Regards,
Smith.

Code:
Option Explicit

Private Sub Cancel_Click()
    Unload Me
End Sub

Private Sub Submit_Click()
    Excel.Application.Cursor = xlWait
    LaunchGamil Me.TextBox1.Value, Me.TextBox2.Value
    Unload Me
    Excel.Application.Cursor = xlDefault
End Sub

Private Sub LaunchGamil(username As String, password As String)
    Const strURL_c As String = "http://mail.google.com"
    Dim objIE As SHDocVw.InternetExplorer
    Dim ieDoc As MSHTML.HTMLDocument
    Dim tbxPwdFld As MSHTML.HTMLInputElement
    Dim tbxUsrFld As MSHTML.HTMLInputElement
    Dim btnSubmit As MSHTML.HTMLInputElement
    On Error GoTo Err_Hnd
    'Create Internet Explorer Object
    Set objIE = New SHDocVw.InternetExplorer
    'Navigate the URL
    objIE.Navigate strURL_c
    'Wait for page to load
    Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
    'Get document object
    Set ieDoc = objIE.Document
    'Get username/password fields and submit button.
    Set tbxPwdFld = ieDoc.all.Item("Passwd")
    Set tbxUsrFld = ieDoc.all.Item("Email")
    Set btnSubmit = ieDoc.all.Item("signIn")
    'Fill Fields
    tbxUsrFld.Value = username
    tbxPwdFld.Value = password
    'Click submit
    btnSubmit.Click
    'Wait for transistion page to load
    Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
    'Wait for main page to load
    Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
Err_Hnd: '(Fail gracefully)
    objIE.Visible = True
End Sub

 

Attachments

  • IE_Example.xls
    34 KB · Views: 62

maninweb

New member
Joined
Mar 22, 2011
Messages
88
Reaction score
0
Points
0
Location
Germany
Website
excel-translator.de
Excel Version(s)
2010, 2016, 2016 Insider
Hi needhelp2...

if I understand it well and you wish to initialize the TextBoxes in your UserForm with
values from your sheet, then you can add following procedure to the code module
of the UserForm...

Code:
Private Sub UserForm_Initialize()
  
  TextBox1.Value = ThisWorkbook.Worksheets("Main").Cells(1, 1).Value
  TextBox2.Value = ThisWorkbook.Worksheets("Main").Cells(2, 1).Value
  
End Sub
UserForm_Initialize() is an event for UserForms and called every time you open
the UserForm. The TextBoxes are here initialized with the values from Cells A1 and A2.

Regards :)
 

needhelp2

New member
Joined
Jul 4, 2011
Messages
2
Reaction score
0
Points
0
Hi needhelp2...

if I understand it well and you wish to initialize the TextBoxes in your UserForm with
values from your sheet, then you can add following procedure to the code module
of the UserForm...

Code:
Private Sub UserForm_Initialize()
  
  TextBox1.Value = ThisWorkbook.Worksheets("Main").Cells(1, 1).Value
  TextBox2.Value = ThisWorkbook.Worksheets("Main").Cells(2, 1).Value
  
End Sub
UserForm_Initialize() is an event for UserForms and called every time you open
the UserForm. The TextBoxes are here initialized with the values from Cells A1 and A2.

Regards :)


wao great Dear Its excel Thanks a lot.I really appreciate your help,Thank you very very much.
 
Top