terdfurgeson
10-09-2015, 06:08 AM
Long story short, using VBA I'm trying to automate the selection of items from multi-value dropdown boxes and run SQL Server Reporting Services (SSRS).
I'm able to get to the page and start to make selections, but I need to check if the element's LABEL equals a certain value. I seem to be unable to locate a simple way to snag the label, as innertext and innerhtml seem to return blank spaces. The goal will be to have a list of names in Excel to match by elementID LABELS and then run the data.
If anyone has a method to scrape the label names for these, I'd LOVE to be able to incorporate it. Any assistance will be highly appreciated.
Sub UM51f()
Dim objIE, element
Dim SSRS As String
Set objIE = CreateObject("InternetExplorer.Application")
SSRS = [Link to SSRS here]
With objIE
.Visible = True
.navigate SSRS
Do Until .readyState = 4
DoEvents
Loop
.navigate [specific SSRS report link here]
Do Until .readyState = 4
DoEvents
Loop
'drop down for selection
Set element = .document.getelementbyid("ctl32_ctl04_ctl03_ddDropDownButton")
element.Click
'This is where I need to check to see if the element's label = a specific name:
Set element = .document.getelementbyid("ctl32_ctl04_ctl03_divDropDown_ctl02")
'trying to print the values to see if they contain usable info:
Debug.Print .document.getelementbyid("ctl32_ctl04_ctl03_divDropDown_ctl02").innertext
Debug.Print .document.getelementbyid("ctl32_ctl04_ctl03_divDropDown_ctl02").innerhtml
element.Click
'More selections:
Set element = .document.getelementbyid("ctl32_ctl04_ctl03_divDropDown_ctl03")
element.Click
Set element = .document.getelementbyid("ctl32_ctl04_ctl03_divDropDown_ctl04")
element.Click
End With
'A few more steps and then submit
End Sub
Sample script data I'm referencing:
<table cellpadding="0" cellspacing="0" style="background-color:window;">
<tr>
<td nowrap="nowrap"><span><input id="ctl32_ctl04_ctl03_divDropDown_ctl00" type="checkbox" name="ctl32$ctl04$ctl03$divDropDown$ctl00" onclick="$get('ctl32_ctl04_ctl03').control.OnSelectAllClick(this);" /><label for="ctl32_ctl04_ctl03_divDropDown_ctl00">(Select All)</label></span></td>
</tr><tr>
<td nowrap="nowrap"><span><input id="ctl32_ctl04_ctl03_divDropDown_ctl02" type="checkbox" name="ctl32$ctl04$ctl03$divDropDown$ctl02" onclick="$get('ctl32_ctl04_ctl03').control.OnValidValueClick(this, 'ctl32_ctl04_ctl03_divDropDown_ctl00');" /><label for="ctl32_ctl04_ctl03_divDropDown_ctl02">Name1</label></span></td>
</tr><tr>
<td nowrap="nowrap"><span><input id="ctl32_ctl04_ctl03_divDropDown_ctl03" type="checkbox" name="ctl32$ctl04$ctl03$divDropDown$ctl03" onclick="$get('ctl32_ctl04_ctl03').control.OnValidValueClick(this, 'ctl32_ctl04_ctl03_divDropDown_ctl00');" /><label for="ctl32_ctl04_ctl03_divDropDown_ctl03">Name2</label></span></td>
</tr><tr>
I'm able to get to the page and start to make selections, but I need to check if the element's LABEL equals a certain value. I seem to be unable to locate a simple way to snag the label, as innertext and innerhtml seem to return blank spaces. The goal will be to have a list of names in Excel to match by elementID LABELS and then run the data.
If anyone has a method to scrape the label names for these, I'd LOVE to be able to incorporate it. Any assistance will be highly appreciated.
Sub UM51f()
Dim objIE, element
Dim SSRS As String
Set objIE = CreateObject("InternetExplorer.Application")
SSRS = [Link to SSRS here]
With objIE
.Visible = True
.navigate SSRS
Do Until .readyState = 4
DoEvents
Loop
.navigate [specific SSRS report link here]
Do Until .readyState = 4
DoEvents
Loop
'drop down for selection
Set element = .document.getelementbyid("ctl32_ctl04_ctl03_ddDropDownButton")
element.Click
'This is where I need to check to see if the element's label = a specific name:
Set element = .document.getelementbyid("ctl32_ctl04_ctl03_divDropDown_ctl02")
'trying to print the values to see if they contain usable info:
Debug.Print .document.getelementbyid("ctl32_ctl04_ctl03_divDropDown_ctl02").innertext
Debug.Print .document.getelementbyid("ctl32_ctl04_ctl03_divDropDown_ctl02").innerhtml
element.Click
'More selections:
Set element = .document.getelementbyid("ctl32_ctl04_ctl03_divDropDown_ctl03")
element.Click
Set element = .document.getelementbyid("ctl32_ctl04_ctl03_divDropDown_ctl04")
element.Click
End With
'A few more steps and then submit
End Sub
Sample script data I'm referencing:
<table cellpadding="0" cellspacing="0" style="background-color:window;">
<tr>
<td nowrap="nowrap"><span><input id="ctl32_ctl04_ctl03_divDropDown_ctl00" type="checkbox" name="ctl32$ctl04$ctl03$divDropDown$ctl00" onclick="$get('ctl32_ctl04_ctl03').control.OnSelectAllClick(this);" /><label for="ctl32_ctl04_ctl03_divDropDown_ctl00">(Select All)</label></span></td>
</tr><tr>
<td nowrap="nowrap"><span><input id="ctl32_ctl04_ctl03_divDropDown_ctl02" type="checkbox" name="ctl32$ctl04$ctl03$divDropDown$ctl02" onclick="$get('ctl32_ctl04_ctl03').control.OnValidValueClick(this, 'ctl32_ctl04_ctl03_divDropDown_ctl00');" /><label for="ctl32_ctl04_ctl03_divDropDown_ctl02">Name1</label></span></td>
</tr><tr>
<td nowrap="nowrap"><span><input id="ctl32_ctl04_ctl03_divDropDown_ctl03" type="checkbox" name="ctl32$ctl04$ctl03$divDropDown$ctl03" onclick="$get('ctl32_ctl04_ctl03').control.OnValidValueClick(this, 'ctl32_ctl04_ctl03_divDropDown_ctl00');" /><label for="ctl32_ctl04_ctl03_divDropDown_ctl03">Name2</label></span></td>
</tr><tr>