programsam
Board Regular
- Joined
- Feb 10, 2016
- Messages
- 123
Alright folks,
I'm trying to set up a file that pulls up a company Intranet via IE, fills in a few fields and then hits "go" to populate a list. It's triggering an "automation" runtime reror because of the Set doc = IE.document line (Line 7) and I suspect is has something to do with "InternetExplorerMedium" but I HAVE to have that setting to maintain IE security.
I'm trying to figure out how to fix this error so I can proceed. The code that I have thus far is as follows:
Any assistance you can provide is much appreciated.
I'm trying to set up a file that pulls up a company Intranet via IE, fills in a few fields and then hits "go" to populate a list. It's triggering an "automation" runtime reror because of the Set doc = IE.document line (Line 7) and I suspect is has something to do with "InternetExplorerMedium" but I HAVE to have that setting to maintain IE security.
I'm trying to figure out how to fix this error so I can proceed. The code that I have thus far is as follows:
Code:
Sub fillForm()
'Establish IE
Dim IE As InternetExplorer
Set IE = New InternetExplorerMedium
Dim doc As HTMLDocument
Set doc = IE.document [COLOR=#ff0000][B]<----getting runtime automation error here[/B][/COLOR]
'Change Settings
Dim activeLink As String
activeLink = "http://thelink"
'Open IE and Navigate to web form
With IE
.navigate activeLink
.Visible = True
'Loop to wait until page loads
Do Until IE.readyState <> READYSTATE_COMPLETE
DoEvents
Loop
End With
'Find IE Form
Dim iframeDoc As MSHTML.HTMLDocument
Set iframeDoc = doc.frames("cAF").frames("iWA") '.document
'Fill out Form
Dim cusType, prSeg, cN As String
cusType = ThisWorkbook.Sheets("data").Range("P2").Value
prSegt = ThisWorkbook.Sheets("data").Range("P3").Value
cN = ThisWorkbook.Sheets("data").Range("P4").Value
With IE.document
iframeDoc.getElementsById("__xmlview1--cusType").Value = cusType
iframeDoc.getElementsById("__xmlview1--prSeg").Value = prSeg
iframeDoc.getElementsById("__xmlview1--cN").Value = cN
'Submit Form
iframeDoc.getElementsById("__xmlview1--idFilterbar-btnGo").Value.Click
End With
'Call macro to pull results
End Sub
Any assistance you can provide is much appreciated.