我无法使用Microsoft Excel VBA自动化Internet Explorer

时间:2018-01-24 12:55:25

标签: excel windows oracle excel-vba oracle-apex vba

我正在尝试使用Microsoft Excel VBA自动将数据输入到Internet Explorer 11上的网站上的文本字段中,并且我的代码适用于我在其上测试过的每个网站(Google,Yahoo等),但一个网站除外我需要它来工作。我需要代码处理的网站是前端的Apex和后端的Oracle。奇怪的是,当运行Windows 7的计算机上打开网站时,相同的代码将适用于Apex网站,而不是在运行Windows 10的计算机上打开时。问题是我需要代码才能在运行的计算机上运行Windows 10.当我在运行Windows 10的计算机上运行代码时,出现以下错误:

     Run-time error '-2147467259(80004005)':

     Automation error
     Unspecified error

有人可以就如何解决这个问题给我任何想法吗?

这是我的VBA代码:

Sub Test()

Dim objIE As Object 

'initiating a new instance of Internet Explorer and asigning it to objIE
Set objIE = CreateObject("InternetExplorer.Application")

'make IE browser visible
objIE.Visible = True

'navigate IE to this web page 
objIE.navigate "This is where I put the website address"

'wait here a few seconds while the browser is busy
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop

'in the Apex web page search textbox put "test"
objIE.document.getElementById("P101_USERNAME").Value = "test"

End Sub

提前谢谢。

0 个答案:

没有答案