我在网上搜索了很多,发现你的网站非常有帮助 - 这就是为什么我还没有发布任何内容,只是阅读。 但是,我需要在项目的以下步骤中提出建议。 该项目旨在自动创建/放置用于销售商品的广告。 该网站是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 LibraryThe 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 SubIf 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:
更多推荐
发布评论