Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
bi bi is offline
external usenet poster
 
Posts: 2
Default how to save a file from a diaglog box using VB or VBA

I have an .asp file that produces an EXCEL file as a result. Now I have
to automate the process of opening the file and saving the resulting
Excel file to the local machine/ desktop.

Right now I can only open the link to the file using (reference:
Microsoft internet controls) :

Sub Test()
Dim IE As New SHDocVw.InternetExplorer
IE.Visible = True
IE.Navigate "http://xlsAllInOne.asp"
End Sub

Now how do i eliminate the popup/dialogue box that comes up asking if
you want to save or open the file. Can that done either from VB or
somewhere in the HTML?

Thanks in advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default how to save a file from a diaglog box using VB or VBA

You don't need to use IE to get the file - you should be able to
download the file directly and save it to disk.

Something like:

Sub FetchFile(sURL As String, sPath As String)
Dim oXHTTP As Object
Dim oStream As Object

Set oXHTTP = CreateObject("MSXML2.XMLHTTP")
Set oStream = CreateObject("ADODB.Stream")

Application.StatusBar = "Fetching " & sURL & " as " & sPath

oXHTTP.Open "GET", sURL, False
oXHTTP.send

With oStream
.Type = adTypeBinary
.Open
.Write oXHTTP.responseBody
.SaveToFile sPath, adSaveCreateOverWrite
.Close
End With

Set oXHTTP = Nothing
Set oStream = Nothing

End Sub


Sub TestSave()
FetchFile "http://xlsAllInOne.asp", ThisWorkbook.Path & "\test.xls"
End Sub


Tim.


"bi" wrote in message
oups.com...
I have an .asp file that produces an EXCEL file as a result. Now I
have
to automate the process of opening the file and saving the resulting
Excel file to the local machine/ desktop.

Right now I can only open the link to the file using (reference:
Microsoft internet controls) :

Sub Test()
Dim IE As New SHDocVw.InternetExplorer
IE.Visible = True
IE.Navigate "http://xlsAllInOne.asp"
End Sub

Now how do i eliminate the popup/dialogue box that comes up asking
if
you want to save or open the file. Can that done either from VB or
somewhere in the HTML?

Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
bi bi is offline
external usenet poster
 
Posts: 2
Default how to save a file from a diaglog box using VB or VBA

Is there a reference Library I should include? It is giving me error at
oXHTTP.Send. I am running this VBA in MS Access or Excel. Both times it
gave the same error.

Thanks
Bi

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default how to save a file from a diaglog box using VB or VBA

I was about to say I used late binding, so you should not need to
reference any other libraries, but then I noticed I had used some
constants from the other libraries.

Try adding refs to
Microsoft XML (mine is v2.6)
Microsoft ActiveX Data Objects (mine is 2.7)


Also, perhaps it doesn't like the URL you're passing to it ?
The URL you posted didn't look valid to me....

Tim.



"bi" wrote in message
oups.com...
Is there a reference Library I should include? It is giving me error
at
oXHTTP.Send. I am running this VBA in MS Access or Excel. Both times
it
gave the same error.

Thanks
Bi



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SAVE and SAVE AS options disappeared from the drop down FILE menu [email protected] Excel Discussion (Misc queries) 2 July 12th 07 09:14 AM
Excell2003 (SP-1) File > Save and File > Save As.. grayed out Joe Murphy Excel Discussion (Misc queries) 0 March 9th 05 10:00 PM
Excel marcos firing on file save as but not file save Andy Excel Programming 1 August 3rd 04 10:34 AM
Save File to Another Directory, but not change Users File Save location Mike Knight Excel Programming 1 May 28th 04 09:06 PM
Custom Diaglog Box Wellie[_2_] Excel Programming 2 February 17th 04 09:39 PM


All times are GMT +1. The time now is 06:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"