Solved

Automate Save As dialog in Internet Explorer from a VB6 or .NET App

Posted on 2004-08-06
6
393 Views
Last Modified: 2008-02-01
Hey Experts,

I am trying to automate the process of order retrieval from a customers ASP app using a VB6 app to open up IE , navigate to the customers site, login, then retrieve the orders from the appropriate page.

I coded to the point where I am at the page with the list of orders. I want to automatically save this page locally. I will then be reading each line of the saved page for the link and then navigating to that page and saving that out as a text file for parsing into our SQL server.

The problem I am having is I can not find the documentation tell me how to do the “save as” once I have navigated to the page.
Does IE's object allow this?

Any direction or help would be greatly appreciated.
0
Comment
Question by:DTRON04
  • 2
6 Comments
 
LVL 15

Expert Comment

by:Walter Ritzel
ID: 11742815
Try this:

in the page that you open, create a javascript with this line of code:

document.execCommand("SaveAs");


Hope this helps,

Walter.
0
 
LVL 3

Expert Comment

by:travisjhall
ID: 11745037
I'd need to check my references at work before I could answer the original question. However, I thought I might suggest an easier way around this. I doubt you really need IE to access the site's page that way. If you've got IE6, you've got MSXML 3.0 (or later), which means you can use the HTTPRequest object to send and receive via HTTP without having to worry about a browser.

I'd have to check my references again for the detail, but off the top of my head you would do something like:

Dim request As MSXML2.HTTPRequest
Set request = New MSXML2.HTTPRequest

request.open "POST", "http://customer.server/loginprocessor.asp", False
request.send "data related to login"

request.open "GET", "http://customer.server/orders.asp", False
request.send


And then request.responseText would be a string representation of the order page, and you can just save that into a file the way you would any other string data.

If you want a bit more of a hand with that approach, let me know and I'll have a quick look for more information when I'm back at work tomorrow.
0
 

Author Comment

by:DTRON04
ID: 11751076
Thanks Travis, yeah if you could give me a few links to a good reference for what you explained. I guess it just reads the HTML as a stream?
Do you know if i can save it as a plain text file or use a parser to strip all of the tags?

Thanks again!
0
 
LVL 3

Accepted Solution

by:
travisjhall earned 500 total points
ID: 11817860
Sorry I haven't gotten back to you about this. Work got busy and I didn't get a chance to look at this again for a while.

I was close on the code, but not quite accurate. This is correct:

Dim request As MSXML2.XMLHTTP
Set request = New MSXML2.XMLHTTP

request.open "GET", "http://qstcsds33/Look/template/Pubview.xml", False
request.send

For PUT method requests, you'll have to do a bit of research yourself, because I haven't done that myself. (Although, it might become necessary in the near future for something I have to do here at work.) The request method changes just by using "PUT" instead of "GET", but I haven't read up on the details of the data to be sent with the PUT request.

request.responseStream will indeed present the data to you as a stream. However, you can also get it as a string with request.responseText. If you want to parse it, you basically get one built-in with request.responseXML, as long as what comes back is well-formed XML (and the recent HTML spec, XHTML, does require that HTML be XML).

A decent starting place for more reading is http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/xmobjxmlhttprequest.asp. However, I would suggest tracking down and downloading the whole SDK, as I find it quite useful.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
stringclean challenge 26 70
Not needed 13 94
Q2. How to run DAX query from SSMS. I don’t see any DAX query type. 1 47
Regular Expression Calculator Tester 2 54
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

21 Experts available now in Live!

Get 1:1 Help Now