0

Basically, I would like to auto login a website, i could find the id= "username" so i could use IE.Document.getElementById("username").value = "xxxxxxx" However, it does not work since there is no value input on Dom. Instead, when i try to edit on HTML DOM by creating new attribute - Value = "xxxxxxx", it shows the username input on website. I wonder if i could transfer this into vba and finish the auto login. Thanks a lot! Error 91 shown regarding to this case

Sub Nomuralogin()

Dim IE As InternetExplorer
Dim Stockcode As String
Dim Stocktext As String, Textchange As String
Dim HTMLDoc As MSHTML.HTMLDocument
Dim IEField As HTMLInputElement
Dim i As Integer, nAsset As Integer

Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "https://www.nomuranow.com/portal/site/nnextranet/en/#curtain- login"
IE.Visible = True

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

Set HTMLDoc = IE.Document
Set IEField = HTMLDoc.getElementById("username")

IEField.Value = "abc@gmail.com"
'HTMLDoc.all.item("username").value = "abc@gmail.com" 
Application.Wait Now + TimeValue("00:00:03")
Application.DisplayAlerts = False

IE.Quit

Set IE = Nothing
End Sub

Pic 1 shows there is no Value input: Pic 1

Pic 2 shows I have created property and added a value input: Pic 2

Captain Obvlious
  • 19,754
  • 5
  • 44
  • 74
  • Possible duplicate of [Fill user name and password in a webpage using VBA](https://stackoverflow.com/questions/24038230/fill-user-name-and-password-in-a-webpage-using-vba) – Jeremy Thompson Aug 31 '17 at 06:31
  • not the same at all. The problem is IE.Document.getElementbyId("username").Value doesn't work at all coz there is no value input on the html dom. I have to create one by myself – Sanngai Wong Aug 31 '17 at 06:37
  • You have not explained that well. Show us your code. You don't even ask a question, and finish telling us that it works when edit the DOM. So it is completely unclear what you're asking gor. – Jeremy Thompson Aug 31 '17 at 06:49
  • Showed my code. Please kindly advise. Thanks – Sanngai Wong Aug 31 '17 at 06:58
  • So HTMLDoc.all.item("username").value doesn't work? That's because it should be IEField.Value = ... Just like the duplicate. Also "Doesn't work" isn't helpful, try providing the error message instead. Good luck! – Jeremy Thompson Aug 31 '17 at 07:18

0 Answers0