+ Reply to Thread
Results 1 to 3 of 3

Get a list of files from a URL

  1. #1
    Registered User
    Join Date
    04-23-2014
    Location
    Melbourne,australia
    MS-Off Ver
    Excel 2013
    Posts
    2

    Get a list of files from a URL

    Hi,

    I want to get a list of all the *.xls files from 'http://www.paj.gr.jp/english/statis/data/07/' using VBA in Excel. I can quess some of the file names and I have some code which copies the file, so if I have a list I could get them all

    Thanks MarkS

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Get a list of files from a URL

    Unfortunately we don't have access to that url


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    04-23-2014
    Location
    Melbourne,australia
    MS-Off Ver
    Excel 2013
    Posts
    2

    Re: Get a list of files from a URL

    You can copy files from there using this code
    Function SaveWebFile(ByVal vWebFile As String, ByVal vLocalFile As String) As Boolean
    Dim oXMLHTTP As Object, vFF As Long, oResp() As Byte

    ' You can also set a ref. to Microsoft XML, and Dim oXMLHTTP as MSXML2.XMLHTTP
    Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")
    oXMLHTTP.Open "GET", vWebFile, False 'Open socket to get the website
    oXMLHTTP.send 'send request

    ' Wait for request to finish
    Do While oXMLHTTP.readyState <> 4
    DoEvents
    Loop
    ' File not found
    If InStr(oXMLHTTP.responseText, "404 Not Found") > 0 Then
    MsgBox ("File Not Found" & Chr(13) & vWebFile)
    Stop
    End If

    oResp = oXMLHTTP.responseBody 'Returns the results as a byte array

    ' Create local file and save results to it
    vFF = FreeFile
    If Dir(vLocalFile) <> "" Then Kill vLocalFile
    Open vLocalFile For Binary As #vFF
    Put #vFF, , oResp
    Close #vFF

    ' Clear memory
    Set oXMLHTTP = Nothing

    End Function

    Sub TestingSaveWebFiles()

    SaveWebFile "http://www.paj.gr.jp/english/statis/data/07/paj-7E_201403.xls", "C:\paj-7E_201403.xls"

    End Sub

    So we have a least read access

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. search list of files in a folder and paste a image from activesheet and paste to files
    By khan.washik in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-25-2012, 01:37 PM
  2. Noob 4 Help - Macro to LIST ALL FILES IN FOLDER and then IMPORT ALL LISTED FILES
    By StlSmiln in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-25-2012, 04:02 AM
  3. Replies: 1
    Last Post: 01-31-2012, 09:07 PM
  4. Delete all files in directory, msgbox list files before delete.
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2010, 09:28 PM
  5. .xml files to be saved as .xls files as XML list
    By Sumi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-27-2006, 04:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1