Subscript out of range

O

OKHM

I will appreciate any one's help on this one :

I found this helpfull macro for downloading URL (Hyperlink in column A) to a
local directory naming the downloaded file with the text in Column D .
By changing it a bit I have tried "making" it loop alog the line2
Unfortunately I couldn't go any further than line 9 - Run-time error '9' -
subscript out of range.
I found it is something to do with the declaration of array or other
parameters this Macro begin with ( even simple macros that work well - like
row count - will stop at row 9 when these declarations are declared.

How can I make it go further down ?

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
' Retreves COA frm Acros and saves it to P\system\mail\COANO.PDF
Sub SAVEURL ()
Dim COANO, row, x, y, z, totalrows
Dim FolderName As String
Dim URL As String
Dim FName As String

x = ActiveCell.row
y = ActiveCell.Column
z = 0
Do While Cells(x, y).Value <> ""
x = x + 1
z = z + 1
row = x
FolderName = "C:\TEST"
URL = Range("A2:A100").Hyperlinks(row).Address
FName = FolderName & "\" & (Cells(x, 4).Value) & ".pdf"
URLDownloadToFile 0&, URL, FName, 0&, 0&
Cells(x, 5).Value = x

Loop
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top