Quote Originally Posted by Yongle View Post
Not my area of expertise, but to help anyone in the forum who may know how to do this:
1 Post the full VBA that works for the single PDF
2 Please put codetags around the code (paste your code, select it, then click on # above)
3 Do not delete any lines, but, if confidentiality is an issue, just use a few XXX's to disguise the web address etc
4 Put a comment on the other threads that you have started saying that the problem is being looked at elsewhere

thanks and - I should have said this earlier - welcome to the forum

Here you go:

This is posted in (I cannot load links, doesn't allow me), check post 138522 in chandoo.org

I found the following thread in other famous excel-VBA user forum: Mr Excel 353006

Three codes are proposed there, the second one would cover my needs:

Sub Test2()
Dim i As Long
Dim FileNum As Long
Dim FileData() As Byte
Dim MyFile As String
Dim WHTTP As Object

On Error Resume Next
Set WHTTP = CreateObject("WinHTTP.WinHTTPrequest.5")
If Err.Number <> 0 Then
Set WHTTP = CreateObject("WinHTTP.WinHTTPrequest.5.1")
End If
On Error GoTo 0

If Dir("C:\MyDownloads", vbDirectory) = Empty Then MkDir "C:\MyDownloads"

For i = 1 To 10
MyFile = Cells(i, 1).Text
TempFile = Right(MyFile, InStr(1, StrReverse(MyFile), "/") - 1)
WHTTP.Open "GET", MyFile, False
WHTTP.Send
FileData = WHTTP.ResponseBody

FileNum = FreeFile
Open "C:\MyDownloads\" & TempFile For Binary Access Write As #FileNum
Put #FileNum, 1, FileData
Close #FileNum
Next
Set WHTTP = Nothing
MsgBox "Open the folder [ C:\MyDownloads ] for the downloaded file..."
End Sub

The info I need to download is password-protected, so I cannot give you the login info for you to take a look, but below is a screen-capture. As you can see, each URL directs the user to a "vault" with few files in there (usually .pdf but also .doc or .gif). What I want is basically to replicate the content of each vault in my local HD. The code above doesn't work for my case, even if you input the file's location (you can know it after you click in the link, the little folder to the right), but since the files come in different formats, the dialog to save them is not always available (Just with the .pdf files seems to work fine), for the rest it would be required to select the file (ctrl+A), copy & paste it to a new document, and save it.

It is probably more complicate that I thought at the beginning, also I need to say that at the same time I posted the same question in other forums, (with no success by the way), should I include links to those here?

By the way, I just found another possible path:
exceltrainingvideos & automate-scraping-of-hyperlinks-from-web-pages-using-excel-vba

If I can make this work, I should be able to get the links to the documents in each URL, then the above mentioned solution should work

I'll try it and post the results!

Regards!

Pegaso

Capture3.JPG