如何通过VBA按上传按钮(How to press Upload button through VBA)

编程入门 行业动态 更新时间:2024-10-24 06:28:50
如何通过VBA按上传按钮(How to press Upload button through VBA)

我在网上搜索了很多,发现你的网站非常有帮助 - 这就是为什么我还没有发布任何内容,只是阅读。 但是,我需要在项目的以下步骤中提出建议。 该项目旨在自动创建/放置用于销售商品的广告。 该网站是http://olx.bg/adding/我未通过VBA做的是按下名为“ДОБАВИСНИМКА”的蓝色方块,其代表表格中的“ADD PHOTO”。 按下后,将打开默认的BROWSE窗口以选择文件。

提前致谢!

I was searching a lot on the web and found your website very helpfull - that is why I have not posted anything yet, just reading. However, I need your advice in the following step of my project. The porject is to automate the creation/placing of ad for selling goods. The website is http://olx.bg/adding/ What I am failing to do through VBA is to press the blue square called "ДОБАВИ СНИМКА" which stands for "ADD PHOTO" in the form. Once pressed a default BROWSE window opens to select the file.

Thanks in advance!

最满意答案

添加两个对VBA项目的引用:

Microsoft Internet Controls Microsoft HTML对象库

按钮后面的HTML有一个id = add-files,这使得使用getElementById很容易找到它

这是一个工作示例:

Sub PushAddPhotoButton() Dim IEexp As InternetExplorer Set IEexp = New InternetExplorer IEexp.Visible = True IEexp.navigate "http://olx.bg/adding/" Do While IEexp.readyState <> 4: DoEvents: Loop Dim photoButton As HTMLInputElement Set photoButton = IEexp.Document.getElementById("add-files") If (Not photoButton Is Nothing) Then photoButton.Click Else MsgBox "Button not found on web page." End If IEexp.Quit Set IEexp = Nothing End Sub

如果Internet上的IE安全设置为“高”,则不会出现对话框或错误。 IE窗口只会闪烁然后消失。

改成:

在此处输入图像描述

Add two references to your VBA project:

Microsoft Internet Controls Microsoft HTML Object Library

The HTML behind the button has an id = add-files which makes it pretty easy to locate using getElementById

Here is a working example:

Sub PushAddPhotoButton() Dim IEexp As InternetExplorer Set IEexp = New InternetExplorer IEexp.Visible = True IEexp.navigate "http://olx.bg/adding/" Do While IEexp.readyState <> 4: DoEvents: Loop Dim photoButton As HTMLInputElement Set photoButton = IEexp.Document.getElementById("add-files") If (Not photoButton Is Nothing) Then photoButton.Click Else MsgBox "Button not found on web page." End If IEexp.Quit Set IEexp = Nothing End Sub

If your IE security settings are on 'High' for Internet then you won't get a dialog or an error. The IE window will simply flash and then be gone.

Change to:

enter image description here

更多推荐

本文发布于:2023-07-17 13:16:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1144990.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按钮   按上   VBA   button   Upload

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!