使用Excel VBA自动化IE导航和数据收集


0

我正在尝试浏览Interent Explorer并使用VBA下载CSV。我知道该网站使用javascript编码为html,但我很难找到我需要使用VBA语法而不是html的点。我也不知道这是否是正确的方法,因为文档,我发现,在线并不具体来涵盖我的具体问题。我明白我可以很容易地使用python执行此操作,但缺乏开始这段旅程的知识。从VBA开始,即使它很慢。

以下是我目前的尝试和首次尝试编码自动化。此外,如果有任何人知道在操作系统被“锁定”而不是“退出”时安排运行宏,这将是非常好的,但是现在我真的只需要一种自动方式来获取这些数据。

Public Sub GrabCSV()

    Dim IE As InternetExplorerMedium
    Dim URL As String
    Set IE = New InternetExplorerMedium
    URL = "http://link"
    With IE
        .Visible = True
        .Navigate URL
    End With

    Do While IE.Busy
        DoEvents
    Loop

    'Current Attempt
    IE.document.form.Select.getElementsByName("01").Selected = True
    IE.document.form.Select.getElementsByName("02").Selected = True
    IE.document.form.Select.getElementsByName("03").Selected = True

    'Attempt 1
    'IE.Document.form("highlight").Select
    'IE.Document.(getElementsByTagName("option").selectedIndex = 1

    'ListBox? - Line Selection
    'Click "Get Dates for All ToolCodes..."
    'Date Selection - 'From Date' and 'To Date'
    'Click "Downtime Report"
    'Click Radio button By Line,Date,DT Code
    'Click "Download Report"
    'Download .csv to folder

End Sub

我拥有我试图导航的网站的源代码。我似乎无法发布它 HTML 格式化 接受它(省略重要的项目)。我将添加一个共享文件的链接 这里 。

选择是 “炉子1,2,3” 和日期范围 “2017年10月3日” 至 “2018年4月18日” 。我需要在Excel文件中下载excel的数据,因为我有其他处理该CSV并将其内容分发到各种文件的宏。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.