【发布时间】:2020-01-23 21:01:18
【问题描述】:
抱歉,如果这有点令人困惑。但是,我在这里有点超出我的深度。我有一个自动化 IE 的宏。有一次,我的宏导航到用于下载报告的 URL。 URL 几乎总是相同的。但是,链接中的一位数字有时会发生变化。链接中发生变化的数字只能是1 或2。获取报告按钮的onclick 事件指示将生成哪个报告。因此,我需要我的宏有一个IF 语句来读取onclick,如果onclick 有1,那么它将导航到带有1 的链接或者如果它是@ 987654329@,它将导航到带有2 的链接。我在下面提供了onclick 的详细信息:
Link with 'ReporttypeID=1'
<input name="btnContinue" class="primary" id="btnContinue" onclick="javascript:pop('Splash.aspx?SplashID=3&../Reports/ReportView.aspx&ReporttypeID=1&lang=EN&ruletypeid=5&ruleid=0'); return false;" type="submit" value="Continue">```
Link with 'ReporttypeID=2'
<input name="btnContinue" class="primary" id="btnContinue" onclick="javascript:pop('Splash.aspx?SplashID=3&../Reports/ReportView.aspx&ReporttypeID=2&lang=EN&ruletypeid=5&ruleid=0'); return false;" type="submit" value="Continue">```
我的代码如下,如何调用/引用 onclick id?
Sub login()
Application.DisplayAlerts = False
Dim url As String
url = UserForm.Path2.Value
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
With ie 'Open IE
.navigate url
ieBusy ie
.Visible = False
ie.navigate "https://mylink.com/ReporttypeID=1" 'Currently navigate to this set link
'Need IF statement to say if onclick = 1 then go to above link, else if it = 2 then go to the below link
'ie.navigate "https://mylink.com/ReporttypeID=2"
ieBusy ie
End With 'End IE actions
Application.DisplayAlerts = True
End Sub
【问题讨论】:
标签: excel vba internet-explorer automation onclick