API_newnoob
New Member
- Joined
- Jun 6, 2020
- Messages
- 21
- Office Version
- 2016
- Platform
- Windows
Hi I am new to this, i watched a few tutorials and tried out on my own and realize that i can't even do a search in the search box of the webpage.
Below is my code that i tried.
I have also upload an image of the webpage and highlight the search box that i want to input a text.
Can someone tell me what i did wrong?
Below is my code that i tried.
VBA Code:
Sub Automate_IE_Load_Page()
'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
'Create InternetExplorer Object
Set IE = CreateObject("InternetExplorer.Application")
'Set IE.Visible = True to make IE visible, or False for IE to run in the background
IE.Visible = True
'Define URL
URL = "https://shopee.sg/"
'Navigate to URL
IE.navigate URL
' Statusbar let's user know website is loading
Application.StatusBar = URL & " is loading. Please wait..."
' Wait while IE loading...
'IE ReadyState = 4 signifies the webpage has loaded (the first loop is set to avoid inadvertently skipping over the second loop)
Do While IE.readyState = 4: DoEvents: Loop 'Do While
Do Until IE.readyState = 4: DoEvents: Loop 'Do Until
'Webpage Loaded
Application.StatusBar = URL & " Loaded"
'what i tried.
'IE.document.getElementById("shopee-searchbar-input").Value = "value" 'Find by ID
'IE.document.getElementById("shopee-searchbar-input__input").Value = "value" 'Find by ID
'IE.document.getElementsByTagName("shopee-searchbar-input").Value = "value" 'Find by tag
'IE.document.getElementsByTagName("shopee-searchbar-input__input").Value = "value" 'Find by tag
'IE.document.getElementsByClassName("shopee-searchbar-input").Value = "value" 'Find by class
'IE.document.getElementsByClassName("shopee-searchbar-input__input").Value = "value" 'Find by class
'IE.document.getElementsByName("shopee-searchbar-input").Value = "value" 'Find by name
'IE.document.getElementsByName("shopee-searchbar-input__input").Value = "value" 'Find by name
'Unload IE
Set IE = Nothing
Set objElement = Nothing
Set objCollection = Nothing
End Sub
I have also upload an image of the webpage and highlight the search box that i want to input a text.
Can someone tell me what i did wrong?