Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.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
Excel 用VBA在IE中填写表单_Excel_Vba_Internet Explorer - Fatal编程技术网

Excel 用VBA在IE中填写表单

Excel 用VBA在IE中填写表单,excel,vba,internet-explorer,Excel,Vba,Internet Explorer,希望在IE中从我工作表上的特定单元格填写表格;研究让我想到: Function FillInternetForm() Dim ie As Object Set ie = CreateObject("InternetExplorer.Application") ie.Navigate "http://helppointinfo.farmersinsurance.com/OCR/Labor_Rates/laborrates.asp" 'go to web page listed

希望在IE中从我工作表上的特定单元格填写表格;研究让我想到:

Function FillInternetForm()
  Dim ie As Object
  Set ie = CreateObject("InternetExplorer.Application")
  ie.Navigate     "http://helppointinfo.farmersinsurance.com/OCR/Labor_Rates/laborrates.asp"
'go to web page listed inside quotes
  ie.Visible = True
  While ie.Busy
    DoEvents  'wait until IE is done loading page.
  Wend
  ie.Document.all("RatesForm").Value = Sheets("NAT").Range("C2").Value

End Function
已更新


人工费率
//更改“输入Zip”文本框或选择“向下搜索Zip”时,将调用该函数
函数FindRates(){
if(document.RatesForm.DirectZip.value+“Empty”!=“Empty”&&document.RatesForm.ZipDD.value+“Empty”!=“Empty”){
if(ValidateZip()){
document.RatesForm.StateDD.value=“”
var strZipCode=document.RatesForm.ZipDD.value
document.getElementById(“ErrorZip”).style.display=“无”
document.getElementsByTagName(“IFRAME”).item(“DisplayReport”).src=“RatesHandler.asp?ZipCode=“+strZipCode
}
否则{
document.getElementById(“ErrorZip”).style.display=“Block”
}
}
else if(document.RatesForm.DirectZip.value+“Empty”!=“Empty”){
if(ValidateZip()){
document.RatesForm.StateDD.value=“”
var strZipCode=document.RatesForm.DirectZip.value
document.getElementById(“ErrorZip”).style.display=“无”
document.RatesForm.submit();
document.getElementsByTagName(“IFRAME”).item(“DisplayReport”).src=“RatesHandler.asp?ZipCode=“+strZipCode
}
否则{
document.getElementById(“ErrorZip”).style.display=“Block”
}
}
}
//从状态下拉列表中选择状态时调用的函数
函数StateRates(){
var strState=document.RatesForm.StateDD.value
document.getElementsByTagName(“IFRAME”).item(“DisplayReport”).src=“RatesHandler.asp?State=“+strState
document.RatesForm.DirectZip.value=“”
document.RatesForm.ZipDD.value=“”
document.getElementById(“ErrorZip”).style.display=“无”
document.getElementById(“TabTag”).style.display=“无”
}
//函数禁用向下钻取压缩以停止双重函数问题
函数disableDD(){
document.RatesForm.ZipDD.disabled=true;
document.getElementById(“TabTag”).style.display=“Block”
}
函数ValidateZip(){
变量re=/^\d{5}([\-]\d{4})$/;
var testBool=re.test(document.RatesForm.DirectZip.value);
返回(testBool);
}
功能禁用键(e){
var键;
if(window.event)
key=window.event.keyCode;//IE
其他的
key=e.which;//firefox
如果(键==13)
返回false;
其他的
返回true;
}
人工费率查询
按拉链
输入Zip
向下钻取拉链
请输入Zip 请输入有效的美国邮政编码! 输入邮政编码并点击Tab。 按州 阿拉巴马州 阿拉斯加州 亚利桑那州 阿肯色州 加利福尼亚 科罗拉多州 康涅狄格州 特拉华州 哥伦比亚区 佛罗里达州 佐治亚州 夏威夷 爱达荷州 伊利诺伊州 印第安纳州 爱荷华州 堪萨斯州 肯塔基州 路易斯安那州 缅因州 马里兰 马萨诸塞州 密歇根 明尼苏达州 密西西比 密苏里州 蒙大拿 内布拉斯加州 内华达州 新罕布什尔州 新泽西州 新墨西哥州 纽约 北卡罗来纳州 北达科他州 俄亥俄州 奥克拉荷马 俄勒冈 宾夕法尼亚 罗德岛 南卡罗来纳州 南达科他州 田纳西州 得克萨斯州 不为人知 犹他州 佛蒙特州 弗吉尼亚州 华盛顿 西弗吉尼亚州 威斯康星州 怀俄明州

我的头撞在墙上,问为什么我在ie文档上总是出错


任何帮助都将不胜感激。

CSS选择器:

你也可以使用
#DirectZip
,将答案放在评论中。 此读取为元素,id为
DirectZip
<代码>#表示id


CSS查询:


VBA:

您可以使用document方法应用CSS选择器:

.document.querySelector("#DirectZip")

“错误”-什么错误?粗体运行时错误“91”:对象变量或未设置块变量,然后突出显示ie.Document.all(“RatesForm”)。Value=Sheets(“NAT”)。Range(“C2”)。Value对于多个注释表示抱歉-第一篇文章和后续注释错误表明
.document.querySelector("#DirectZip")