Hi Tom,
Thanks for responding. I had posted the following on 9/28, but received no
responses:
-----I have been using a web query to post data to a cgi
script, but the website has switched to an ASP form. Can
anyone shed some light on how text data should be posted
to an active server page using an Excel web query?
Specifically, I am posting a stock symbol
to "http://www.cboe.com/DelayedQuote/QuoteTableDownload.asp
x" in order to download a file "QuoteData.dat"-----
In reading past posts to the group, I noticed that at least one other person
has experienced the same problem as I have with the CBOE website. At this
point I have been able to use SHELL, AppActivate, and SENDKEYS to download
files in a macro, but I have to insert delays and the overall approach is far
from elegant, with error handling and branching being difficult. I would
still like to find a better approach, but I do not know how to handle
submission to ASP.NET. Any suggestions you have would be appreciated. The
CBOE site does not have a password and the URL is:
http://www.cboe.com/DelayedQuote/Quo...eDownload.aspx
Thanks
Mehlin
"Tom Ogilvy" wrote:
A common usage similar to what you describe is to pull down stock data. If
you are doing that, it can often be done with a web query.
In any event, perhaps if you post your URL (given it isn't password
protected) and a description of what you are trying to do, perhaps you can
get better help.
--
regards,
Tom Ogilvy
"mehlin" wrote in message
...
Robin,
Thanks for the response. The difficulty I have with URLDownloadToFile is
that I am trying to posting information and get a file returned in
response.
The file is not associated with a specific URL, but is generated by the
server as a result of form input by the user.
"Robin Hammond" wrote:
I've never used SendKeys, but why not try the API call
URLDownloadToFile.
Robin Hammond
www.enhanceddatasystems.com
"mehlin" wrote in message
...
I am using AppActivate and Sendkeys in a macro to download a file with
Internet Explorer. With the code sequence below, I am able to enter a
string
and bring up a "File Download" dialog box, but I have not been able to
initiate the download with SendKeys. The code is shown below.
I first used Sendkeys without using AppActivate to shift focus to the
"File
Download" window, but the keystrokes were apparently ignored after the
"File
Download" window appeared, without generating an error.
After inserting the line --AppActivate "File Download" 'bring focus
to
FileDownload window"-- I received an error.
My question is: How do I use AppActivate and Sendkeys to complete a
file
download with Internet explorer by way of the File Download and Save
As
dialog boxes? Do I need to explicitly shift focus to the File Download
window
(or Save As window), and if not, what keystrokes should I be using? I
would
greatly appreciate any pointers, and I hope that I have presented my
problem
intelligibly.
Thanks
-----------------
Sub File_download()
'Start Asynchronous instance of IE
ProgID = Shell("C:\Program Files\Internet Explorer\IExplore.EXE", 3)
'
Run IE Explorer
'Insert Delay to allow IE to load page
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 8
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.wait (waitTime)
'Bring focus to IE
AppActivate ProgID
'Tab to text input box on webform
SendKeys "{TAB}"
'enter symbol string to text box
SendKeys "MSFT"
'Tab to Download button
SendKeys "{TAB}"
'Initiate download
SendKeys "{ENTER}", True 'File Download box appears in IE at
this
point
AppActivate "File Download" 'bring focus to FileDownload window"
'error
occurs here
SendKeys "%S"
'enter filename string after Save As dialog box appears
SendKeys "test.txt"
SendKeys "{ENTER}"
End Sub