The macro code(using selenium basic) is basically stock data stacking program that collects data from DSE: Dhaka Stock Exchange using xPathonUrl
function() in excel macro and then show the real time data (paid up capital, Ownership data : Period, Sponsor/Director(%),Government(%),Institute(%),Foreign(%), Public(%)) in the excel sheet.
Problem is, it performs perfectly in my PC and some of my friends' too, but not in the seniors' PC for whom I basically build the project to retrieve real time stock data.
The code is:
Sub PaidupCapital()
Dim autobot As New WebDriver, By As New By
autobot.AddArgument "--headless"
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
autobot.Start "chrome"
autobot.Wait (3300)
For i = 5 To lastrow
autobot.Wait (3300)
link = Sheets(2).Range("a" & i).Value
autobot.ExecuteScript "window.open(arguments[0])", link
autobot.SwitchToNextWindow
autobot.Wait (3300)
If autobot.IsElementPresent(By.XPath("//*[@id='consent-page']/div/div/div/div[2]/div[2]/form/button")) Then
autobot.FindElementByXPath("//*[@id='consent-page']/div/div/div/div[2]/div[2]/form/button").Click
End If
paidcapital = autobot.FindElementByXPath("/html/body/div[2]/section/div/div[3]/div[1]/div/div[4]/table/tbody/tr[2]/td[1]").Text
Sheets(2).Range("I" & i).Value = paidcapital
foreign = autobot.FindElementByXPath("/html/body/div[2]/section/div/div[3]/div[1]/div/div[11]/table/tbody/tr[6]/td[2]/table/tbody/tr/td[4]").Text
Sheets(2).Range("Y" & i).Value = foreign
pub = autobot.FindElementByXPath("/html/body/div[2]/section/div/div[3]/div[1]/div/div[11]/table/tbody/tr[6]/td[2]/table/tbody/tr/td[5]").Text
Sheets(2).Range("Z" & i).Value = pub
institute = autobot.FindElementByXPath("/html/body/div[2]/section/div/div[3]/div[1]/div/div[11]/table/tbody/tr[6]/td[2]/table/tbody/tr/td[3]").Text
Sheets(2).Range("X" & i).Value = institute
govt = autobot.FindElementByXPath("/html/body/div[2]/section/div/div[3]/div[1]/div/div[11]/table/tbody/tr[6]/td[2]/table/tbody/tr/td[2]").Text
Sheets(2).Range("W" & i).Value = govt
director = autobot.FindElementByXPath("/html/body/div[2]/section/div/div[3]/div[1]/div/div[11]/table/tbody/tr[6]/td[2]/table/tbody/tr/td[1]").Text
Sheets(2).Range("V" & i).Value = director
Period = autobot.FindElementByXPath("/html/body/div[2]/section/div/div[3]/div[1]/div/div[11]/table/tbody/tr[6]/td[1]").Text
Sheets(2).Range("U" & i).Value = Period
Next i
MsgBox "Congratulations! Data has beed updated :)"
End Sub
question from:
https://stackoverflow.com/questions/65866482/a-problem-named-out-of-memory-in-ms-excel-macro-as-this-occurs-only-in-some-pcs 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…