2014-01-24 730 views
2

我在Access数据库表单中写入了下列表单。使用MS Access VBA提交HTML表单

Function Submit_Web_Form() 

Dim ie As Object 

Set ie = CreateObject("internetexplorer.application") 

    ie.navigate "http://www.webstaurantstore.com/bakers-pride-bco-e2-cyclone-series-electric-convection-oven-double-deck/155BCOE2.html" 

    ie.Visible = True 

While ie.busy 
    DoEvents 
Wend 

ie.Document.all("from").Value = "Add" 
ie.Document.all("weight").Value = "0" 
ie.Document.all("price").Value = "5400.00" 
ie.Document.all("description").Value = "Bakers%20Pride%20BCO%2DE2%20Cyclone%20Series%20Electric%20Convection%20Oven%20Double%20Deck" 
ie.Document.all("uom").Value = "Each" 
ie.Document.all("shipping").Value = "C" 
ie.Document.all("taxcode").Value = "Y" 
ie.Document.all("mnbuy").Value = "1" 
ie.Document.all("mxbuy").Value = "1" 
ie.Document.all("suffix").Value = "Voltage" 
ie.Document.all("group").Value = "Y" 
ie.Document.all("item_number").Value = "155BCOE2 240/1" 
ie.Document.all("qty").Value = "1" 
ie.Document.Forms(0).submit 

While ie.busy 
    DoEvents 
Wend 

Set ie = Nothing 

End Function 

虽然函数不会产生任何错误,但它不会提交表单。我需要自动将产品添加到购物车中。

有没有人有任何使用VBA处理网页的经验?

感谢先进!

+1

有使用MS Access和做一些这个疯狂与它的给予好评。您的表单是否填充了您在代码中设置的值? – sh1rts

+1

我认为你应该考虑使用XMLHTTPRequest对象。看到这篇文章:http://stackoverflow.com/questions/3963475/http-post-in-vba – HK1

+0

给shrts:我们有一个全国连锁餐厅,我们不断订购大量的设备。我们基本上在Access数据库中有整个网站,并加快查找感兴趣的项目。这个想法是通过Access将其添加到购物车,然后打开资源管理器并完成结帐。为了回答你的问题,在这个例子中,我们简化了代码,而不使用变量作为值来测试这个想法并追踪问题出在哪里。 – user3230254

回答