Hi,
I’d like to create a macro which would generate entries in a database filling a IE form from an Excel file (1 page for each line of the Excel file)
The steps are :
Can someone please help ?
So far the macro opens the IE page
When I try to fill a field nothing happen and I have the following message : "method 'Document' of object IWebBrowser2' failed
When I try to save the form nothing happen and I have the following message : "method 'Document' of object IWebBrowser2' failed
Here is my code so far :
Sub Fill_IE_Form()
Dim ie As Object
Dim objElement As Object
Dim objCollection As Object
Dim ws As Worksheet
Dim i As Integer
Dim lastrow As Integer
' open Excel sheet where the data is stored
Set ws = ThisWorkbook.Sheets("Data")
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate ("https://Path/NewForm.aspx?RootFolder=")
ie.FullScreen = False
'wait until page is loaded + tempo
Do While ie.readyState = 4: DoEvents: Loop ''''Application.Wait Now + TimeValue("00:00:05")
'ie.Document.getElementById("Title_fa564e0f-0c70-4ab9-b863-0177e6ddd247_$TextField").Value = "PPP"
'ie.Document.getElementbyid("TDDemandDesc_6f4f3e35-b3cc-4e25-a2e2-9acd8995bd52_$TextField_inplacerte").Value = "VVV"
'ie.Document.getElementById("SubmitToApprobationButton").Click
Set ie = Nothing
End Sub
I’d like to create a macro which would generate entries in a database filling a IE form from an Excel file (1 page for each line of the Excel file)
The steps are :
- Declare the variables
- Dim ws As Worksheet
- Dim i As Integer
- Dim lastrow As Integer
- Dim ie As Object
Dim objElement As Object
Dim objCollection As Object
- Open the Excel worksheet “Data”
- Set ws = ThisWorkbook.Sheets("Data")
- Open a IE page “mypage”
- ie.navigate ("https://Path/NewForm.aspx?RootFolder=")
- Temporisation to ensure the page is loaded
- Do While ie.readyState = 4: DoEvents: Loop
- Fill textboxes with the content of the Excel sheet cells ws.Cells(i, 1), ws.Cells(i, 2), ws.Cells(i, 3), ws.Cells(i, 4)
- Type=”text” id=”textbox1” , Type=”text” id=”textbox2” Type=”text” id=”textbox3” Type=”text” id=”textbox4”
- Click the “submit” button
- Type=”button” id=”submit_button”
- Increment i and fill another entry (loop steps 3 to 6)
- Loop until ws.Cell(i, 2) is empty
Can someone please help ?
So far the macro opens the IE page
When I try to fill a field nothing happen and I have the following message : "method 'Document' of object IWebBrowser2' failed
When I try to save the form nothing happen and I have the following message : "method 'Document' of object IWebBrowser2' failed
Here is my code so far :
Sub Fill_IE_Form()
Dim ie As Object
Dim objElement As Object
Dim objCollection As Object
Dim ws As Worksheet
Dim i As Integer
Dim lastrow As Integer
' open Excel sheet where the data is stored
Set ws = ThisWorkbook.Sheets("Data")
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate ("https://Path/NewForm.aspx?RootFolder=")
ie.FullScreen = False
'wait until page is loaded + tempo
Do While ie.readyState = 4: DoEvents: Loop ''''Application.Wait Now + TimeValue("00:00:05")
'ie.Document.getElementById("Title_fa564e0f-0c70-4ab9-b863-0177e6ddd247_$TextField").Value = "PPP"
'ie.Document.getElementbyid("TDDemandDesc_6f4f3e35-b3cc-4e25-a2e2-9acd8995bd52_$TextField_inplacerte").Value = "VVV"
'ie.Document.getElementById("SubmitToApprobationButton").Click
Set ie = Nothing
End Sub