Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default saving workbook from URL

Is it possible to write a macro to save a workbook from URL to my c drive.

eg : i want to save a workbook from "http://...../abc.xla" to
"C:\.....\abc.xla" on a click of a button.

Suggestions will be greatly appreciated.

Thanks,
--
Ajit
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default saving workbook from URL

This was posted recently by Mudraker: (primary code from Randy Birch's site)

http://groups.google.com/groups?selm...&output=gplain.


'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
' Copyright ©1996-2003 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long


Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000


Public Function DownloadFile(sSourceUrl As String, _
sLocalFile As String) As Boolean


'Download the file. BINDF_GETNEWESTVERSION forces
'the API to download from the specified source.
'Passing 0& as dwReserved causes the locally-cached
'copy to be downloaded, if available. If the API
'returns ERROR_SUCCESS (0), DownloadFile returns True.

DownloadFile = URLDownloadToFile(0&, _
sSourceUrl, sLocalFile, _
BINDF_GETNEWESTVERSION, _
0&) = ERROR_SUCCESS

End Function


' Mukraker's code to call the function


Sub AutoDownloadIntranetFile()
Dim sSourceUrl As String
Dim sLocalFile As String
Dim hfile As Long


sSourceUrl = "http://www.??????"
sLocalFile = "c:\temp"
If DownloadFile(sSourceUrl, sLocalFile) = False Then
Call cmdE
MsgBox "Error In Downloading File" _
& Chr(10) _
& "Cannot Continue", vbCritical
End
End If
End Sub


sub cmdE()
AppActivate "microsoft excel"
end Sub


--
Regards,
Tom Ogilvy


"Ajit" wrote in message
...
Is it possible to write a macro to save a workbook from URL to my c drive.

eg : i want to save a workbook from "http://...../abc.xla" to
"C:\.....\abc.xla" on a click of a button.

Suggestions will be greatly appreciated.

Thanks,
--
Ajit



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default saving workbook from URL

Hi Ajit,

Another option is to use XMLHTTP and ADODB to do it. Here's a link to a
function I wrote to copy any file via HTTP:

http://groups-beta.google.com/group/...f364286?rnum=2


--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Ajit wrote:
Is it possible to write a macro to save a workbook from URL to my c
drive.

eg : i want to save a workbook from "http://...../abc.xla" to
"C:\.....\abc.xla" on a click of a button.

Suggestions will be greatly appreciated.

Thanks,


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
Color Changes When Saving 2007 Workbook as 97 - 2003 Workbook Don Excel Discussion (Misc queries) 0 April 20th 08 04:51 AM
Saving Workbook Jeff Excel Discussion (Misc queries) 1 March 30th 07 07:57 PM
Saving Workbook Jako[_62_] Excel Programming 5 August 6th 04 05:28 PM
Saving a Workbook: Forcing User to Rename before Saving Rollin_Again[_6_] Excel Programming 5 April 16th 04 02:54 PM
Saving workbook from vba Don[_12_] Excel Programming 1 December 10th 03 08:53 AM


All times are GMT +1. The time now is 01:15 PM.

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

About Us

"It's about Microsoft Excel"