Link to home
Start Free TrialLog in
Avatar of TimHudspith
TimHudspith

asked on

Recording full HTTP address that appears in Explorer's status bar to a string variable.

I'm developing an application that stores a list of files and their locations at various web addresses. These details are stored in the application so that the files can be downloaded automatically each month using URLDownloadToFile in one fell swoop.

I want the user to load up the file details as follows:
1. Open an instance of explorer
2. Navigate to a site that holds several comboboxes which determine which file is downloaded
3. User makes the usual selections from the combo boxes, then presses "Export to Excel"
4. At this point, everything that has happened so far is part of the normal manual download process. Once the "Export . . ." button is pressed, a download dialog box opens asking the user whether he wants to open or save. It is at this point that the full HTTP address (including the filename) shows in Explorer's status bar in the bottom left. I need a way of recording this address to a string variable that will be displayed in a ListView in my application (and eventually passed to URLDownloadToFile when the user performs the monthly automatic download process).

Does anyone know the answer?
SOLUTION
Avatar of kaliyugkaarjun
kaliyugkaarjun

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of justchat_1
justchat_1

kaliyugkaarjun is correct
You could also use the beforenavigate2 event to record that message...it will appear as the url string
Avatar of TimHudspith

ASKER

kaliyugkaarjun / justchat 1 - Thanks, that's just what I was looking for.

However, I made a mistake in my original question. There are two major websites that we download from.
1. The first has a series of hyperlinked filennames on the webpage. When I click one of these, the full URL path WITH filename appears in the status bar. Therefore there are no problems with this scenario.
2. The other is as in my original question. The user makes selections from a series of combos to indicate the report he wants to download (bookname, PNL, monthend date) and then clicks the export button to download. In this scenario, only the URL and directory path appears in the status bar; the filename is absent. The only place the actual filename appears is in the download dialog box. So, how can I grab the filename?

It should also be in the beforenavigate2 event...
> User makes series of combos to indicate the report he wants to download....
Plz xplain in detail...can u????
kaliyugkaajun -

This is an an in-house finance website where different accounting departments of a bank can download the trade-level P&L information for their area. The first combo box is a list of different dates; the second is a list of trading books; the third is actually two option buttons: P&L or balance sheet. Having make the selections the user hits a button saying "Export to Excel".

On pressing this button a download dialog box appears saying "Download xyzBook_20060531.csv" with a "Save" "Open" and "Cancel" button.

Now at this point the following is displayed in the status bar: "Downloading from http://inHouseWebsite/DailyPNLs/csvFiles . . . . " but NOT the filename. I've done string processing on the statusText property as advised above so that I have a 'clean' URL ("http/ . . . ./csvFiles"), but what I need is the URL AND filename in a single string. How do I get the filename - the only place it appears is in the download dialog box.

I suppose I could download the .html page and analyse the entires in the various controls to get the filename but what a pain!
Did you try the beforenavigate2 event? or the navigate2 event?
justchat 1

Yes, I did use beforenavigate2, however I found that it didn't capture changes in the status text when the combo selections were made, nor when the final "Exoprt to Excel" button was pressed, so I'm using the CommandStateChange event handler. This does the job, but I'm still left with a string minus the filename.

This is not such a big problem as I've now got some code that recognises the URL string for this site and returns a default filename that will only require a small amount of manual alteration.
If i am wrone plz correct me..
The user selects the file from second combo box right??? or am still confused ...:(
On the webpage or in the controls you don't actually see a filename, as such. Rather they offer different selections for each component of the filename.  The components of each filename are this: bookname & yyyymmdd & "PNL" / "BS" & .xls.  Imagine I work for TRADINGBOOKxyz, and I want to get the profit & loss file for that book as at 20060531; I make the following selections in the combo boxes:

combo 1 : "TRADINGBOOKxyz"
combo 2 : "20060531"
combo 3 : "PNL"

Then I hit a command button which brings up the dialog box "Do you want to save or open this file : TRADINGBOOKxyz_20060531_PNL.csv ?"

At this point the status bar reads: "Downloading from http://blahblah/folder1/folder2/folder3" which is fine, in terms of being the correct directory path, but I have no way of automatically grabbing the filename that appears in the dialog box. I don't think Explorer has a property that contains the end result of the selections I've made from the combos.

Don't worry if you can't help with this last part. I'm happy with the info you've given me.
The big question is what does the source code look like for the page?
I have a feeling thats a script that is passing you the files...
justchat1 - this is outside my knowledge area unfortunately. Is there any way I can access this code?
when viewing the webpage right-click and select view source...it should pop-up in notepad
justchat 1 - the mists are beginning to clear a little.  

I need to give you a little more background about this website. It's actually called "XML converter" as all the files are in XML format. When the user makes his selections and presses the button, what actually happens first is that the original XML file is converted to CSV before downloading. I did a test download using code and all I got was a file with about 100 lines of XML tags, no actual CSV file. So I need some way of sending instructions to this page that replicates the combo-selecting and button-pressing.

I did what you said: made my combo selections and pressed the download button, thereby generating a download dialog box. At this point I right-clicked: view source. There was lots of script but you can clearly see the bits that relate to the combos and option buttons, including the selections I made. I hope this all makes sense to you. If it's possible for me to send script to the website to generate a file then it would represent a major breakthrough. Thanks for your help in advance.

<?xml version="1.0" encoding="UTF-8"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w9.org/OV/xhtml1/DTD/strict.dtd"/>
<head><title>MIS Sign-Off Tool</title>
<link rel="STYLESHEET" type="text/css" href="../css/standard.css">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="cache-control" content="no-cache">
<link rel='stylesheet' type='text/css' media='all' href='../css/calendar-db_intranet.css'/>
<script type='text/javascript' src='../js/calendar/calendar.js'></script>
<script type='text/javascript' src='../js/calendar/lang/calendar-en.js'></script>
<script type='text/javascript' src='../js/calendar/calendar-setup.js'></script>
</head>
<html>
<body>
<script language="JavaScript1.2"><!--
function setDate(date) {
sobForm.date.value = date;
}
function exportToExcel() {
sobForm.action='CheckSize';
sobForm.submit();
}
function refreshInputs(accioname) {
/* 1--> LOCATION, 2--> BUSINESS, 3-->SOB */
 switch (accioname) {
 case 1: sobForm.business.value='';
 case 2: sobForm.sob.value='';
 case 3: sobForm.portfolio.value='';
 }
sobForm.action='CSVExporter';
sobForm.submit();
sobForm.location.disabled="true";
sobForm.sob.disabled="true";
sobForm.portfolio.disabled="true";
sobForm.business.disabled="true";
}
// -->
</script>      
<img src="../images/xml_converter.gif" width="400" height="55" border="0" alt="Refreshing Status"/>
<br />
<br />
<table border="0" cellspacing="0" cellpadding="0">
<form name="sobForm" method="POST" action="CSVExporter" >
 <colgroup width="100">
 <col />
 <col />
 <col />
 <col width='20'/>
 <col />
 <col align="center" width="35"/>
 <col align="center" width="35"/>
 <col align="center" width="35"/>
 <col />
 <col align="right"/>
</colgroup>
<tr>
<td colspan="10" background="../images/bg_table1.gif">
<img src="../images/bg_table2.gif" width="26" height="5" border="0"><br></td>
</tr>
<tr>
<td colspan="10" background="../images/bg_raster.gif" class="tblbld">Book Details<br></td>
</tr>
<tr bgcolor=#EEEEEE class="tbl">
 <td>Location</td>
 <td>Business</td>
 <td>Sign-Off Group</td>
 <td>&nbsp;</td>
 <td>Portfolio</td>
 <td>Risk</td>
 <td>PnL</td>
 <td>Att</td>
 <td>File</td>
 <td>&nbsp</td>
</tr>
<tr>
<td>
<select name="location" id="location" onchange="refreshInputs(1)">
<option value="FFM" >FFM</option>
<option value="LDN" selected>LDN</option>
<option value="NYC" >NYC</option>
<option value="SGP" >SGP</option>
<option value="SYD" >SYD</option>
<option value="TOK" >TOK</option>
<option value="TOR" >TOR</option>
</select></td>
<td>
<select name="business" id ="business" onchange="refreshInputs(2)">
<option value="COM" >COM</option>
<option value="EM" >EM</option>
<option value="FI" >FI</option>
<option value="GEPS" >GEPS</option>
<option value="GFX" >GFX</option>
<option value="GFXO" >GFXO</option>
<option value="GMFCE" >GMFCE</option>
<option value="ICT" >ICT</option>
<option value="MMD" >MMD</option>
<option value="MMR" >MMR</option>
<option value="OTC" selected>OTC</option>
<option value="POOL" >POOL</option>
<option value="SCM" >SCM</option>
<option value="SCT" >SCT</option>
<option value="STIRT" >STIRT</option>
<option value="USPG" >USPG</option>
<option value="VSG" >VSG</option>
</td></select>
<td>
<select name="sob" id="sob" onchange="refreshInputs(3)">
<option  value="BOOK_1">BOOK_1</option>
<option  value="BOOK_2">BOOK_2</option>
<option  value="BOOK_3">BOOK3</option>
<option  value="BOOK_4">BOOK_4</option>
<option  value="BOOK_5">BOOK_5</option>
<option  value="BOOK_6">BOOK_6</option>
<option  value="BOOK_7">BOOK_7</option>
</td></select>
<td>&nbsp;</td>
<td>
<select name="portfolio" id="portfolio">
<option  value="BOOK_1">BOOK_1</option>
</td></select>
<td><input type="radio" name="class" value="RISK" ></input></td>
<td><input type="radio" name="class" value="PNL" checked></input></td>
<td><input type="radio" name="class" value="ATT" ></input></td>
<td>
<select name="version"><option selected value='official'>official</option><option  value='flash'>flash</option></select>
</td>
<input type="hidden" name="date" value="31/05/2006"></input>
<td><input type="button" class="buttons" value="Export to Excel" onClick="exportToExcel()"></input></td>
</tr>
<input type="hidden" name="reset" value="false"></input>
</form>
</table>
<br />
<div style='width: 12em;' id='calendar-container'></div>
<script type='text/javascript'>
  Calendar.setup(
    {
            flat         : 'calendar-container', // ID of the parent element
            flatInputField : 'date',
            ifFormat : '%d/%m/%Y',       // format of the input fieldn
            disableFuture    : false, // disable dates beyond today
            application      : 'CVSExporter', //Choose the application
            disableWkend     : true,
            date :  '05/31/2006'
    }
  );
</script>
</body>
</html>
Actually now I come to think of it, it's impractical to keep transforming XML files to CSV for every single visitor to this site (there are hundreds each day). There must be an underlying directory structure where all the CSV files sit. What I suspect is happening is that I am not getting the full URL address from the status bar, because the .StatusText property I grab reads like this:

http://blahblah.mb.com/folder1/folder2/folder3/CheckSize . . .

There's an elipsis at the end, suggesting there's more, but how can I get this full path?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help both.

Kaliyugkaarjun - you answered my question, so thanks for that.
JustChat1 - thanks also, you've pointed me in a direction that might get my script-related download problem solved.

Cheers