VBA coding

Jenil Xavier

New Member
Joined
Nov 2, 2018
Messages
2
Hi. I'm working on coding to automate filling details in users form. Before entering into user form I need select a form name from drop down list. Once selected IE page loads and wait time is around 3 secs. Then need to update details. Now I'm trying to automate this process by using VBA script. So far I have written code until selecting form name, but user form does not displays. Please help..
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
.
For anyone to assist, it would be best to post the code you currently have.
 
Upvote 0
.
For anyone to assist, it would be best to post the code you currently have.

Dim IE As Object
Set IE = CreateObject(InternetExplorer.Application")
IE.Visible=True

IE.nagivate"https://Google.com" ( for eg I used google webpage)
Do
Doevents
Loop Until IE.Readystate=4

Set ActivityGroup=IE.document.getelementbyid)"ContentBody_ddlActivityGroup")
For I=1 to ActivityGroup.Options.Length
If ActivtyGroup.Options(I).value="India" Then (post India is selected from drop down user form related to India has to open)
ActivityGroup.SelectedIndex=I
Exit For
End if
Next I
Do
DoEvents
Loop Until IE.Readystate=4
End Sub

This is the code from webpage
<Select name="ctl00$contentBody$ddlActivityGroup" onchange="javascript:setTimeout('__doPostBack(\'ctl00$contentBody$ddlActivityGroup\',\'\')', 0)" id="contentBody_ddlActivityGroup" style="width:295px;">
<option selected="selected" value="-1></option>
<option value="India">India</option>
<option value="USA">USA</option>
<option value="UK">UK</option>
</select>
 
Upvote 0
.
Your macro has a number of errors ... here is a basic macro to open a webpage in IE :

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://www.Google.com/"
 
    '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"
    
    'Unload IE
    Set IE = Nothing
    Set objElement = Nothing
    Set objCollection = Nothing
    
End Sub


If the form selection is located on the webpage ... that is beyond my knowledge ... I will not be able to assist.
 
Upvote 0
Thanks for sharing,

Just to ask if possible

I have filled the data in web page 1, and submit. It opens to redirect to another web page.
Now here somehow I am not able to search the elements to fill, or NEW IE web page is not responding , what could be the issue?
 
Upvote 0
.
Regretfully I am not familiar with web page interaction. Hopefully someone else can assist you.

I wish you well in your endeavour.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top