【发布时间】:2016-10-27 04:37:50
【问题描述】:
如何根据 .txt 文件中的列表循环/运行代码,直到列表结束?
如何根据 .txt 文件中的列表循环/运行代码,直到列表结束?
Sub FundData()
Dim TikerName As String
TikerName = 'check & execute the names in list one after one in .txt file until it ends up
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://example.com/index.php?name=" & TikerName, Destination:=Range( _
"$A$1"))
'.CommandType = 0
.Name = "name=" & TikerName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = """company"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveSheet.Name = TikerName
Sheets.Add After:=ActiveSheet
ThisWorkbook.Save
End Sub
【问题讨论】:
-
“结束了??”嗯?
-
300+个raw中大概有300+个字符串,意思是txt文件的最后(行)字符串,比如TikerName.txt
标签: html vba excel web-scraping html-tableextract