Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.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和InternetExplorer提交表单和阅读结果_Excel_Vba_Internet Explorer_Web Scraping - Fatal编程技术网

使用Excel VBA和InternetExplorer提交表单和阅读结果

使用Excel VBA和InternetExplorer提交表单和阅读结果,excel,vba,internet-explorer,web-scraping,Excel,Vba,Internet Explorer,Web Scraping,我正在使用Excel VBA提交表单,同时使用InternetExplorer对象。提交后,我可以在屏幕上看到URL的更改。但是,当我尝试输出URL(确认它已更改并且代码知道它)时,我会得到相同的URL 在下面的两个调试语句中,它们输出相同的URL 代码: readystate_complete上的查询只能以这种方式运行一次。之后,状态保持不变。因此,如有必要,您可以手动暂停 'The last three values are hours, minutes, seconds 'This wai

我正在使用Excel VBA提交表单,同时使用InternetExplorer对象。提交后,我可以在屏幕上看到URL的更改。但是,当我尝试输出URL(确认它已更改并且代码知道它)时,我会得到相同的URL

在下面的两个调试语句中,它们输出相同的URL

代码:


readystate_complete上的查询只能以这种方式运行一次。之后,状态保持不变。因此,如有必要,您可以手动暂停

'The last three values are hours, minutes, seconds
'This waits for 5 seconds
Application.Wait (Now + TimeSerial(0, 0, 5))
另一种方法是使用循环等待,直到找到已知的html元素。查看此示例了解更多信息:

使用循环的另一个示例:

对象仍与启动时相同,因此url将保持不变。在获取更新信息之前,您需要更新对象。@Mech我使用两个不同的调用来设置doc=ie.document。我还需要做更多的工作?我还尝试了ie.LocationUrl,但这也没有改变。使用
Application.wait(现在+TimeSerial(0,0,5))
重置第二次等待。等待5秒钟。你可以根据自己的需要缩短时间。我认为您的代码在提交表单后不会等待,因为IE的状态已经是
完成
@Zwenn,这似乎是解决我问题的方法。如果你给出答案,我可以接受。
'The last three values are hours, minutes, seconds
'This waits for 5 seconds
Application.Wait (Now + TimeSerial(0, 0, 5))