Solved

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

Posted on 2004-08-06
6
395 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 16

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

823 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