Solved

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

Posted on 2006-06-18
17
235 Views
Last Modified: 2010-04-07
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?
0
Comment
Question by:TimHudspith
  • 8
  • 6
  • 3
17 Comments
 
LVL 8

Assisted Solution

by:kaliyugkaarjun
kaliyugkaarjun earned 400 total points
ID: 16933097
U must hav used WebBrowser Objects in ur program..

The StatusText property provides a mechanism for assigning a text string to the lower left-hand section of the StatusBar previously modified. This property performs the same action as commonly performed via scripting within a web page.

IE.StatusText gives u text at de bottom left corner of Explorer's window... (it can be set by user also i think)

chk out this link more help...
http://www.vbcity.com/page.asp?f=books-wrox-vbweb&p=chapter

0
 
LVL 9

Expert Comment

by:justchat_1
ID: 16937492
kaliyugkaarjun is correct
You could also use the beforenavigate2 event to record that message...it will appear as the url string
0
 

Author Comment

by:TimHudspith
ID: 16937766
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?

0
 
LVL 9

Expert Comment

by:justchat_1
ID: 16938131
It should also be in the beforenavigate2 event...
0
 
LVL 8

Expert Comment

by:kaliyugkaarjun
ID: 16940189
> User makes series of combos to indicate the report he wants to download....
Plz xplain in detail...can u????
0
 

Author Comment

by:TimHudspith
ID: 16940375
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!
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 16947661
Did you try the beforenavigate2 event? or the navigate2 event?
0
 

Author Comment

by:TimHudspith
ID: 16948647
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.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 8

Expert Comment

by:kaliyugkaarjun
ID: 16948751
If i am wrone plz correct me..
The user selects the file from second combo box right??? or am still confused ...:(
0
 

Author Comment

by:TimHudspith
ID: 16949036
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.
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 16954169
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...
0
 

Author Comment

by:TimHudspith
ID: 16954370
justchat1 - this is outside my knowledge area unfortunately. Is there any way I can access this code?
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 16955363
when viewing the webpage right-click and select view source...it should pop-up in notepad
0
 

Author Comment

by:TimHudspith
ID: 16958215
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>
0
 

Author Comment

by:TimHudspith
ID: 16963261
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?
0
 
LVL 9

Accepted Solution

by:
justchat_1 earned 100 total points
ID: 16964116
Thats very strange I didnt think statustext would cut off like that...

As far as that source-if anyone with javascript knowledge could post thats a little over my head.
I imagine you could replicate the form post but i cant figure out where the form is posting to...
0
 

Author Comment

by:TimHudspith
ID: 16978418
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
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now