Access is Denied Error

B

Bruce

Hi,

When I run the following function I get 'Access is Denied' at line '
objWeb.Send'. The exact same Function works in another database I have, on
the same system with the same reference.

Any ideas what the problem might be?

Bruce


Function YahooQuotes(URL As String)
Dim objWeb As Object
Dim intFile As Integer
Dim strFile As String
Dim strHTML As String
Set objWeb = CreateObject("Microsoft.XMLHTTP")
objWeb.Open "GET", URL, False
objWeb.Send
strHTML = objWeb.responseText
strFile = CurrentProject.Path & "\Download\" & "YahooDownload.csv"
intFile = FreeFile()
Open strFile For Output As #intFile
Print #intFile, strHTML
Close #intFile
End Function
 
B

Bruce

Hi Alex - I first though that might be the case since I have another function
that builds the URL string. By stepping thtough the macro I have copied/paste
the URL string from the local window into my browser and it works fine.

Below I have attached my full module. I call updateYahooRTQ_US to kick off
this process.

Any thoughts?

Bruce



Function updateYahooRTQ_US()
DoCmd.SetWarnings False
myWatchlist = Array("q_Watchlist_US")

'On Error Resume Next

For Each Watchlist In myWatchlist
Call YahooQuotes(rtQuote(CStr(Watchlist)))
DoCmd.OpenQuery "q_tbl_YahooDownload_csv_append", acViewNormal,
acEdit
Next Watchlist

Call upd_YahooTime
Call upd_XL
DoCmd.SetWarnings True
End Function

Function YahooQuotes(URL As String)
Dim objWeb As Object
Dim intFile As Integer
Dim strFile As String
Dim strHTML As String
Set objWeb = CreateObject("Microsoft.XMLHTTP")
objWeb.Open "GET", URL, False
objWeb.Send
strHTML = objWeb.responseText
strFile = CurrentProject.Path & "\Download\" & "YahooDownload.csv"
intFile = FreeFile()
Open strFile For Output As #intFile
Print #intFile, strHTML
Close #intFile
End Function

Function mySecList(myRST As String) As String
Dim DB As DAO.Database
Dim Rst As DAO.Recordset
Set DB = CurrentDb()
Set Rst = DB.OpenRecordset(myRST)
l = 1
Do Until Rst.EOF

If l = 1 Then
mySecList = Rst!YahooCode
Else
mySecList = mySecList & "+" & Rst!YahooCode
End If
l = l + 1
Rst.MoveNext
Loop
Rst.Close
Set Rst = Nothing
Set DB = Nothing
End Function

Function rtQuote(myRST As String) As String
rtQuote = "http://finance.yahoo.com/d/quotes.csv?s=" & mySecList(myRST)
& "&f=sd1t1b3b2l1c6ohgva2"
End Function
 

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