web scraping - How to scrape web data in vba -


i have followed jsotola's suggestion , recorded following macro, encountered error, how can solve it? run time error 91 , following code has been highlighted

selection.listobject.tableobject.refresh

sub macro1()      activeworkbook.queries.add name:="1-1-1", formula:= _         "let" & chr(13) & "" & chr(10) & "    source = web.page(web.contents(""http://www.hkjc.com/english/racing/horse.asp?horseno=v099""))," & chr(13) & "" & chr(10) & "    data0 = source{0}[data]," & chr(13) & "" & chr(10) & "    #""changed type"" = table.transformcolumntypes(data0,{{""column1"", type text}, {""column2"", type text}, {""column3"", type text}})" & chr(13) & "" & chr(10) & "in" & chr(13) & "" & chr(10) & "    #""changed type"""     activeworkbook.queries.add name:="1-1-2", formula:= _         "let" & chr(13) & "" & chr(10) & "    source = web.page(web.contents(""http://www.hkjc.com/english/racing/horse.asp?horseno=v099""))," & chr(13) & "" & chr(10) & "    data1 = source{1}[data]," & chr(13) & "" & chr(10) & "    #""changed type"" = table.transformcolumntypes(data1,{{""column1"", type text}, {""column2"", type text}, {""column3"", type text}, {""column4"", type text}})" & chr(13) & "" & chr(10) & "in" & chr(13) & "" & chr(10) & "    #""changed type"""     workbooks("book1").connections.add2 "query - table 0", _         "connection 'table 0' query in workbook.", _         "oledb;provider=microsoft.mashup.oledb.1;data source=$workbook$;location=table 0" _         , """table 0""", 6, true, false     workbooks("book1").connections.add2 "query - table 1", _         "connection 'table 1' query in workbook.", _         "oledb;provider=microsoft.mashup.oledb.1;data source=$workbook$;location=table 1" _         , """table 1""", 6, true, false     sheets.add after:=activesheet     selection.listobject.tableobject.refresh     sheets.add after:=activesheet     selection.listobject.tableobject.refresh end sub 

enter image description here


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -