Jigar B
New Member
I am working on some automation wherein data will be in excel and need to update the fields in website using excel values.
I found this macro online and tried to edit it, but its not working.
Please advice so I can proceed further with updation of fields once login is succesful.
I have added following referances:
Microsoft HTML Object Library
Microsoft Internet controls
Questions: Tried running it in IE8. Do I need to update to IE 11?
Received error: Method 'Document' of object 'IWebBrowser2' failed on line
Changed: I have updated to IE11 and now the error is changed to "Automation error, unspecified error"
I found this macro online and tried to edit it, but its not working.
Please advice so I can proceed further with updation of fields once login is succesful.
I have added following referances:
Microsoft HTML Object Library
Microsoft Internet controls
Questions: Tried running it in IE8. Do I need to update to IE 11?
Received error: Method 'Document' of object 'IWebBrowser2' failed on line
Changed: I have updated to IE11 and now the error is changed to "Automation error, unspecified error"
Code:
IE.document.getelementsbyname("_58_login").Value = "jigarjigar"
Code:
Public Declare PtrSafe Function SetForegroundWindow Lib "user32" (ByVal HWND As Long) As Long
Sub Automate_IE_Enter_Data()
'This will load a webpage in IE
Dim i As Long
Dim URL As String
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
Dim HWNDSrc As Long
Dim document As HTMLDocument
'Create InternetExplorer Object
Set IE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
'Set IE = CreateObject("InternetExplorer.Application")
'True to make IE visible, or False for IE to run in the background
IE.Visible = True
'Navigate to URL
IE.Navigate [URL]https://www.asite.com/login-home/[/URL]
' Wait while IE loading...
Do While IE.ReadyState = 4: DoEvents: Loop
'Get Window ID for IE so we can set it as activate window
HWNDSrc = IE.HWND
'Set IE as Active Window
SetForegroundWindow HWNDSrc
'Find & Fill Out Input Box
IE.document.getelementsbyname("_58_login").Value = "jigarjigar"
IE.document.getelementsbyname("_58_password").Value = "mypassword"
IE.document.getelementsbyclassname("btn-submit nobgcolor").Click
'Unload IE
endmacro:
Set IE = Nothing
Set objElement = Nothing
Set objCollection = Nothing
End Sub
Attachments
Last edited: