0

I am creating a function in excel, which is supposed to save multiple PDF files into a folder, but the PDF files must be downloaded from hyperlinks.

Is it possible to select multiple shells that have hyperlinks attached, and to create a function that will recognize the selection and download the PDFs from the web pages?

What I did so far is, a sub routine which creates a folder on my desktop. I struggle with downloading the PDF files in the folder.

Dim fdObj As Object

Application.ScreenUpdating = False

Set fdObj = CreateObject("Scripting.FileSystemObject")

If fdObj.FolderExists("C:\Users\" & Environ("UserName") & "\Desktop\Temp folder") 

Then

    MsgBox "Found it.", vbInformation, "Excel"

Else

    fdObj.CreateFolder ("C:\Users\" & Environ("UserName") & "\Desktop\Temp folder")

    MsgBox "It has been created.", vbInformation, "Excel"

End If

Application.ScreenUpdating = True
  • you can find two solutions for downloading here [how-do-i-download-a-file-using-vba-without-internet-explorer](https://stackoverflow.com/questions/17877389/how-do-i-download-a-file-using-vba-without-internet-explorer) – Yane Apr 17 '19 at 06:17

1 Answers1

0

Read first here and here

Multithreading a For Loop

Sub RunForVBA(workbookName As String, seqFrom As Long, seqTo As Long)
    For i = seqFrom To seqTo
        x = seqFrom / seqTo
    Next i
End Sub

Sub RunForVBAMultiThread()
    Dim parallelClass As Parallel 

    Set parallelClass = New Parallel 

    parallelClass.SetThreads 4 

    Call parallelClass.ParallelFor("RunForVBA", 1, 1000) 
End Sub

Run an Excel macro asynchronously

Sub RunAsyncVBA(workbookName As String, seqFrom As Long, seqTo As Long)
    For i = seqFrom To seqTo
        x = seqFrom / seqTo
    Next i
End Sub

Sub RunForVBAAndWait()
    Dim parallelClass As Parallel

    Set parallelClass  = New Parallel

    Call parallelClass.ParallelAsyncInvoke("RunAsyncVBA", ActiveWorkbook.Name, 1, 1000) 
    'Do other operations here
    '....

    parallelClass.AsyncThreadJoin 
End Sub
Dmitrij Holkin
  • 1,995
  • 3
  • 39
  • 86