我是 Excel VBA 的新手。这就是问题所在:给定一个标识符,我想从网页中检索一些文本。理想情况下,我想将页面文本存储在单个单元格中。我创建了一个创建 QueryTable 的函数,但有时,检索到的文本会复制到多行上。
有没有办法将所有文本放在一个单元格上?
这是我的函数的代码:
Function Articolo(myRange As Range, code As String)
Dim myURL As String
Dim myName As String
myURL = "URL;http://techstore.runner.it/feed/dettagli_csv.php?codcli=111367&pwd=03142110786&sku=" & code
myName = "dettagli_csv.php?codcli=111367&pwd=03142110786&sku=" & code
With ActiveSheet.QueryTables.Add(Connection:= _
myURL _
, Destination:=myRange)
.Name = myName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = False
.WebConsecutiveDelimitersAsOne = False
.WebSingleBlockTextImport = True
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.WebConsecutiveDelimitersAsOne = True
.Refresh BackgroundQuery:=False
End With
End Function
作为测试,您可以使用 8E4374 作为代码
谢谢你的帮助!