Solved

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

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

713 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