Anda di halaman 1dari 7

'BSE Cose

D1B5633F0E3E7425FE98A15EAA
Dim iLoop, sCompName, sURL, sCP
Dim oXMLHTTP, SearchChar, TempContent, strPos, Current_Price, Open_Price, Day_Hi
gh, Day_Low, Year_High, Year_Low, Buy_Quantity, Sell_Quantity, temp
Set objApp = CreateObject("Excel.Application")
Set objWbs = objApp.WorkBooks
objApp.Visible = True
Set objWorkbook = objWbs.Open("C:\Rajesh Data\Stock\Stock_Data.xls")
Set objSheet = objWorkbook.Sheets("Sheet1")
Set oXMLHTTP = CreateObject( "Microsoft.XMLHttp")
For iLoop= 2 to 1498
sCP = objSheet.Range("B" + Cstr(iLoop)).Value
If sCP = "" Then
sCompName = objSheet.Range("A" + Cstr(iLoop)).Value
sURL = "http://www.sharekhan.com/News/CompanyDetailedQuote.aspx?Exchange=BSE&ssk
icode="+sCompName
'print(Cstr(iLoop) + ". " + sURL)
With oXMLHTTP
' Send request
.open "GET",sURL , False
.send
'Get Response Data
Stats=.statusText
sResponse = .responseText
' Get Current Price
SearchChar = "lblCP"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Current_Price = Left(TempContent, (strPos - 1))
objSheet.Range("B" + Cstr(iLoop)).Value = Current_Price
' Get Open Price
SearchChar = "lblOP"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Open_Price = Left(TempContent, (strPos - 1))
objSheet.Range("C" + Cstr(iLoop)).Value = Open_Price
' Get Day High Price
SearchChar = "lblDH"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Day_High = Left(TempContent, (strPos - 1))
objSheet.Range("D" + Cstr(iLoop)).Value = Day_High
'Gt Day Low Price
SearchChar = "lblDL"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Day_Low = Left(TempContent, (strPos - 1))
objSheet.Range("E" + Cstr(iLoop)).Value = Day_Low
' Get Year High Price
SearchChar = "lbl52WH"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Year_High = Left(TempContent, (strPos - 1))
objSheet.Range("F" + Cstr(iLoop)).Value = Year_High
' Get Year Low Price
SearchChar = "lbl52WL"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Year_Low = Left(TempContent, (strPos - 1))
objSheet.Range("G" + Cstr(iLoop)).Value = Year_Low
' Get Buy Quantity
SearchChar = "lblBQ"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Buy_Quantity = Left(TempContent, (strPos - 1))
objSheet.Range("H" + Cstr(iLoop)).Value = Buy_Quantity
' Get Sell Quantity
SearchChar = "lblSQ"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Sell_Quantity = Left(TempContent, (strPos - 1))
objSheet.Range("I" + Cstr(iLoop)).Value = Sell_Quantity
End with
End If
Next
Set oXMLHTTP = Nothing
objWorkbook.Save
objWorkbook.Close
objWbs.Close
objApp.Quit
Set objSheet = Nothing
Set objWorkbook = Nothing
Set objWbs = Nothing
Set objApp = Nothing

'NSE code
Dim iLoop, sCompName, sURL
Dim oXMLHTTP, SearchChar, TempContent, strPos, Current_Price, Open_Price, Day_Hi
gh, Day_Low, Year_High, Year_Low, Buy_Quantity, Sell_Quantity, temp
Set objApp = CreateObject("Excel.Application")
Set objWbs = objApp.WorkBooks
objApp.Visible = True
Set objWorkbook = objWbs.Open("C:\Rajesh Data\Stock\Stock_Data.xls")
Set objSheet = objWorkbook.Sheets("Sheet1")
Set oXMLHTTP = CreateObject( "Microsoft.XMLHttp")
For iLoop= 2 to 1498
sCompName = objSheet.Range("A" + Cstr(iLoop)).Value
sURL = "http://www.sharekhan.com/News/CompanyDetailedQuote.aspx?Exchange=NSE&ssk
icode="+sCompName
'print(Cstr(iLoop) + ". " + sURL)
With oXMLHTTP
' Send request
.open "GET",sURL , False
.send
'Get Response Data
Stats=.statusText
sResponse = .responseText
' Get Current Price
SearchChar = "lblCP"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Current_Price = Left(TempContent, (strPos - 1))
objSheet.Range("B" + Cstr(iLoop)).Value = Current_Price
' Get Open Price
SearchChar = "lblOP"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Open_Price = Left(TempContent, (strPos - 1))
objSheet.Range("C" + Cstr(iLoop)).Value = Open_Price
' Get Day High Price
SearchChar = "lblDH"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Day_High = Left(TempContent, (strPos - 1))
objSheet.Range("D" + Cstr(iLoop)).Value = Day_High
'Gt Day Low Price
SearchChar = "lblDL"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Day_Low = Left(TempContent, (strPos - 1))
objSheet.Range("E" + Cstr(iLoop)).Value = Day_Low
' Get Year High Price
SearchChar = "lbl52WH"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Year_High = Left(TempContent, (strPos - 1))
objSheet.Range("F" + Cstr(iLoop)).Value = Year_High
' Get Year Low Price
SearchChar = "lbl52WL"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Year_Low = Left(TempContent, (strPos - 1))
objSheet.Range("G" + Cstr(iLoop)).Value = Year_Low
' Get Buy Quantity
SearchChar = "lblBQ"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Buy_Quantity = Left(TempContent, (strPos - 1))
objSheet.Range("H" + Cstr(iLoop)).Value = Buy_Quantity
' Get Sell Quantity
SearchChar = "lblSQ"
strPos = Instr(1, sResponse, SearchChar, 1)
TempContent = Left(sResponse, (strPos + 20))
TempContent = Right(TempContent, 20)
strPos = InStr(1, TempContent, ">", 1)
TempContent = Right(TempContent, (20 - strPos))
strPos = InStr(1, TempContent, "<", 1)
Sell_Quantity = Left(TempContent, (strPos - 1))
objSheet.Range("I" + Cstr(iLoop)).Value = Sell_Quantity
End with
Next
Set oXMLHTTP = Nothing
objWorkbook.Save
objWorkbook.Close
objWbs.Close
objApp.Quit
Set objSheet = Nothing
Set objWorkbook = Nothing
Set objWbs = Nothing
Set objApp = Nothing

' Ordering
' Categories the Companies
Dim iLoop, YH, Range
Set objApp = CreateObject("Excel.Application")
Set objWbs = objApp.WorkBooks
objApp.Visible = False
Set objWorkbook = objWbs.Open("C:\Rajesh Data\Stock\Stock_Data.xls")
Set objSheet = objWorkbook.Sheets("Sheet1")
'*******************************************************************************
*****************
For iLoop = 2 to 1498
YH = objSheet.Range("F"+Cstr(iLoop)).Value
If YH = Null Then
Range = "Check"
elseIf YH < 100 Then
Range = 100
elseif YH < 200 then
Range = 200
elseif YH < 300 then
Range = 300
elseif YH < 400 then
Range = 400
elseif YH < 500 then
Range = 500
elseif YH < 600 then
Range = 600
elseif YH < 700 then
Range = 700
elseif YH < 800 then
Range = 800
elseif YH < 900 then
Range = 900
elseif YH < 1000 then
Range = 1000
elseif YH < 1500 then
Range = 1500
elseif YH < 2000 then
Range = 2000
elseif YH < 2500 then
Range = 2500
elseif YH < 3000 then
Range = 3000
elseif YH < 3500 then
Range = 3500
elseif YH < 4000 then
Range = 4000
elseif YH > 4000 then
Range = 4500
End If
objSheet.Range("J"+Cstr(iLoop)).Value = Range
Next
'*******************************************************************************
**************
objWorkbook.Save
objWorkbook.Close
objWbs.Close
objApp.Quit
Set objSheet = Nothing
Set objWorkbook = Nothing
Set objWbs = Nothing
Set objApp = Nothing
MsgBox "Done"

' email
Dim oOApp
Dim oOMail
Set oOApp = CreateObject("Outlook.Application")
Set oOMail = oOApp.CreateItem(olMailItem)
With oOMail
.To = "csraj239@gmail.com"
.Subject = "email subject"
.Body = "Mail of Succss"
.Send
End With
oOApp.quit

8010747324

Anda mungkin juga menyukai