Sub loginWebWeX()
Dim htmldoc As HTMLDocument
Dim frm As Object
Dim objCollection As Object
Dim browser As InternetExplorer
Dim link As Object
Dim mainurl
Dim grandtotalinventory As Long
mainurl = ThisWorkbook.Sheets(1).Range("B1")
Set browser = New InternetExplorer
'On Error Resume Next
browser.Visible = True
browser.navigate mainurl
Do While browser.Busy Or browser.ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop
Set htmldoc = browser.document
'Set objCollection = htmldoc.frames.Length
j = 1
i = 0
Do
Loop Until Not (browser.Busy)
Set objCollection = htmldoc.frames(0).document.getElementsByTagName("a")
For Each link In objCollection
If link.innerHTML = "Log In" Then
link.Click
End If
Next
Set htmldoc = browser.document
Do
Loop Until Not (browser.Busy)
Set objCollection = htmldoc.frames(1).document.getElementsByTagName("input")
k = 0
While k < objCollection.Length
If objCollection(k).Name = "userName" Then
objCollection(k).Value = ThisWorkbook.Sheets(1).Range("A1")
objCollection(k).Focus
Application.SendKeys ("{ENTER}")
ElseIf objCollection(k).Name = "password" Then
objCollection(k).Value = ThisWorkbook.Sheets(1).Range("A2")
ElseIf objCollection(k).ID = "mwx-btn-logon" Then
Application.Wait (Now + TimeValue("0:00:03"))
objCollection(k).Click
End If
k = k + 1
Wend
Set objCollection = Nothing
Set objElement = Nothing
Set htmldoc = Nothing
Set browser = Nothing
Exit Sub
errorhandler:
MsgBox Err.Description
End Sub
Dim htmldoc As HTMLDocument
Dim frm As Object
Dim objCollection As Object
Dim browser As InternetExplorer
Dim link As Object
Dim mainurl
Dim grandtotalinventory As Long
mainurl = ThisWorkbook.Sheets(1).Range("B1")
Set browser = New InternetExplorer
'On Error Resume Next
browser.Visible = True
browser.navigate mainurl
Do While browser.Busy Or browser.ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop
Set htmldoc = browser.document
'Set objCollection = htmldoc.frames.Length
j = 1
i = 0
Do
Loop Until Not (browser.Busy)
Set objCollection = htmldoc.frames(0).document.getElementsByTagName("a")
For Each link In objCollection
If link.innerHTML = "Log In" Then
link.Click
End If
Next
Set htmldoc = browser.document
Do
Loop Until Not (browser.Busy)
Set objCollection = htmldoc.frames(1).document.getElementsByTagName("input")
k = 0
While k < objCollection.Length
If objCollection(k).Name = "userName" Then
objCollection(k).Value = ThisWorkbook.Sheets(1).Range("A1")
objCollection(k).Focus
Application.SendKeys ("{ENTER}")
ElseIf objCollection(k).Name = "password" Then
objCollection(k).Value = ThisWorkbook.Sheets(1).Range("A2")
ElseIf objCollection(k).ID = "mwx-btn-logon" Then
Application.Wait (Now + TimeValue("0:00:03"))
objCollection(k).Click
End If
k = k + 1
Wend
Set objCollection = Nothing
Set objElement = Nothing
Set htmldoc = Nothing
Set browser = Nothing
Exit Sub
errorhandler:
MsgBox Err.Description
End Sub