PDA

View Full Version : Save file as excel through xl macro from web- in existing code



aravindhan_3
07-02-2010, 08:59 AM
The below code works as for
. Open Internet explorer
enter date in particular field,
click view report
and click export to excel

Till here the macro works without any problem


Sub OpenWebpageAndLogin()

Dim objIE As Object

Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Navigate "http://aaa/a/aae=1"
Do While .Busy: DoEvents: Loop
Do While .readyState <> 4: DoEvents: Loop
.Visible = True

.Document.getElementById("date_date").Value = "30-Jun-2010"
.Document.getElementById("ReportsSearch_Button_0").Click
Do While .Busy: DoEvents: Loop
Do While .readyState <> 4: DoEvents: Loop
.Document.getElementById("ReportsSearch_Button_4").Click
End With Set objIE = Nothing
Set objIE = Nothing
End Sub


But it tells the user to save or cancel? is there a way to automate this piece ? dont prompt just save the file as excel in C drive.

I tried the usual way in VBA
.Save, .Save as etc it is not working...

Note: The webpage address is hidden as it is confidential

Crocus Crow
07-03-2010, 05:44 AM
SendKeys might work... if you're lucky. URLDownloadToFile if there's a direct link to the file, otherwise FindWindow and other Windows API functions would probably work.