Expand|Select|Wrap|Line Numbers
- ============================================
- Option Explicit
- Function ImportBhavCopy(dtFrom As Date, dtTo As Date)
- On Error GoTo errHandler
- Dim dtDate As Date
- For dtDate = dtFrom To dtTo Step -1
- 'Debug.Print GetURL(dtDate)
- DoCmd.TransferText acImportDelim, "", "Quotes", GetURL(dtDate), True, ""
- Next
- errHandler:
- Debug.Print err.Number & " " & err.Description
- Exit Function
- End Function
- Function GetURL(dtTemp As Date) As String
- Dim strTemp As String
- strTemp = "http://www.nseindia.com/content/historical/EQUITIES/"
- strTemp = strTemp & GetYear(dtTemp) & "/"
- strTemp = strTemp & UCase(GetMonthName(dtTemp)) & "/cm"
- strTemp = strTemp & GetDay(dtTemp)
- strTemp = strTemp & UCase(GetMonthName(dtTemp))
- strTemp = strTemp & GetYear(dtTemp) & "bhav.csv"
- GetURL = strTemp
- End Function
- Function GetMonthName(dtTemp As Date) As String
- GetMonthName = MonthName(Month(dtTemp), True)
- End Function
- Function GetDay(dtTemp As Date) As String
- If Day(dtTemp) < 10 Then
- GetDay = "0" & CStr(Day(dtTemp))
- Else
- GetDay = CStr(Day(dtTemp))
- End If
- End Function
- Function GetYear(dtTemp As Date) As String
- GetYear = CStr(Year(dtTemp))
- End Function
- ============================================