Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript VBA自动执行Internet Explorer 8错误_Javascript_Excel_Internet Explorer 8_Vba - Fatal编程技术网

Javascript VBA自动执行Internet Explorer 8错误

Javascript VBA自动执行Internet Explorer 8错误,javascript,excel,internet-explorer-8,vba,Javascript,Excel,Internet Explorer 8,Vba,我正在尝试自动化一个工作流程,我们进入我们的内部互联网网站 单击名为“导入”的按钮。弹出一个javascript窗口。我们从组合框中选择一个值。我们需要从组合框下方的不同下拉菜单中选择“替换”值。最后,单击新窗口上的导入按钮 我对VBA比较陌生,我可以打开网站并单击导入按钮,但我无法在javascript窗口中引用组合框。另外,我有Internet Explorer 8,无法升级到10或11 我不能下载第三方软件来像autoit那样为我自动化,因为这是我的工作笔记本电脑,而且它受到限制 我尝试使

我正在尝试自动化一个工作流程,我们进入我们的内部互联网网站

单击名为“导入”的按钮。弹出一个javascript窗口。我们从组合框中选择一个值。我们需要从组合框下方的不同下拉菜单中选择“替换”值。最后,单击新窗口上的导入按钮

我对VBA比较陌生,我可以打开网站并单击导入按钮,但我无法在javascript窗口中引用组合框。另外,我有Internet Explorer 8,无法升级到10或11

我不能下载第三方软件来像autoit那样为我自动化,因为这是我的工作笔记本电脑,而且它受到限制

我尝试使用doc.getElementsById,但代码找不到对象

以下是我的代码:

Sub modulogin()

“需要激活两个引用:Microsoft Internet对象和Microsoft HTML。”
'http://open-twebst.codecentrix.com/ 用于录制web宏
Dim IE作为InternetExplorer
作为HTMLDocument的Dim doc
作为HTMLFormElement的Dim LoginForm
作为HTMLInputButtonElement的Dim ImportButton按钮
将cbo设置为HTMLSELECT元素
Set IE=新的InternetExplorer
可见=真实
例如,卷曲
'等待加载初始页面
在IE.readyState readyState_完成或IE.Busy:DoEvents:Loop时执行
Set doc=IE.document
'获取页面上唯一的表单
设置LoginForm=doc.forms(“aspnetForm”)
设置ImportButton=LoginForm.elements(16)'如果我尝试使用LoginForm.elements(“ctl00$ContentPlaceHolder1$btnImport”),它将找不到该按钮
导入按钮。单击
设置cbo=LoginForm.GetElementById(“FormularyComboBox\u Input”)’如果我尝试使用LoginForm.elements(“FormularyComboBox”)它cbo=nothing
cbo.Value=“2015 GG”
端接头
下面是我在javascript对话框中检查组合框时HTML代码的样子:


单击按钮后,您可能需要在循环等待IE加载下一个表单时执行另一个Do。您提供的HTML代码不是真正的
组合框。但是在DOM的其他地方可能存在一个真正的组合框,其中包含要选择的列表和值。如果您找到它,那么您可以轻松设置正确的“选择”值。
'Need to activate two references: Microsoft Internet Object and Microsoft HTML
'http://open-twebst.codecentrix.com/ use to record web macros

Dim IE As InternetExplorer
Dim doc As HTMLDocument
Dim LoginForm As HTMLFormElement
Dim ImportButton As HTMLInputButtonElement
Dim cbo As HTMLSelectElement

Set IE = New InternetExplorer

IE.Visible = True
IE.navigate cURL

'Wait for initial page to load

Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop

Set doc = IE.document

'Get the only form on the page

Set LoginForm = doc.forms("aspnetForm")

Set ImportButton = LoginForm.elements(16) 'If I try to use LoginForm.elements("ctl00$ContentPlaceHolder1$btnImport") it won't find the button

ImportButton.Click

Set cbo = LoginForm.GetElementById("FormularyComboBox_Input") 'If I try to use LoginForm.elements("FormularyComboBox") it cbo = nothing 

cbo.Value = "2015 GG"

End Sub