PostText entry

Mike UK

New Member
Joined
Dec 14, 2011
Messages
43
I am trying to use posttext within a web query to extract data from our intranet. The web page uses a combo box with various options which automatically refreshes the web page with the new data when selected. I am trying to use a macro and posttext to select the data I wish. The macro is written as follows:-

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://intranet/PR/AdvancedSearchScreen2.aspx?Type=1&Level=4&Crit=P181&StartLevel=1&StartParent=" _
, Destination:=Range("A1"))
.PostText = "__EVENTTARGET=DisplaySelect&__EVENTARGUMENT=actual_weight&DisplaySelect=actual_weight"
.Name = _
"AdvancedSearchScreen2.aspx?Type=1&Level=4&Crit=P181&StartLevel=1&StartParent="
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub


The relevant part of the source code for the web page shows:-
******** language="javascript" type="text/javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
theform = document.Form1;
}
else {
theform = document.forms["Form1"];
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
*********>

<table cellSpacing="0" cellPadding="0" width="100%">
<tr>
<td><span id="TitleLabel" class="REPORT_HDR">Asset Level Search Report</span></td>
<td align="right"><a id="ExportLink" href="AdvancedSearchExport.aspx?Screen=2&Type=1&Level=4&Crit=P181&FieldName=model_drift_value&AllocLevel=1&ParentCode=" target="_blank">Export to Excel</a>
  |  <a href="javascript:window.close();">Close Window</a>
</td>
</tr>
<tr height="25">
<td><span id="SearchLabel">You searched on <b>'P181'</b><br></span></td>
<td></td>
</tr>
<tr height="35">
<td><select name="DisplaySelect" onchange="__doPostBack('DisplaySelect','')" language="javascript" id="DisplaySelect" class="TEXTBOX">
<option value="actual_value">Actual Value</option>
<option value="actual_weight">Actual Weight</option>
<option value="breach_value">Breach Value</option>
<option value="breach_weight">Breach Weight</option>
<option selected="selected" value="model_drift_value">Model Drift Value</option>
<option value="model_drift_weight">Model Drift Weight</option>
<option value="benchmark_drift_value">Benchmark Drift Value</option>
<option value="benchmark_drift_weight">Benchmark Drift Weight</option>


Any ideas?
Thanks....
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,223,701
Messages
6,173,910
Members
452,537
Latest member
the little giant

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top