Solved

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

Posted on 2004-08-06
6
391 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

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

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.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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 …

771 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

11 Experts available now in Live!

Get 1:1 Help Now