[英]Excel VBA QueryTables Preserve Hyperlinks
我在 VBA 中大量使用QueryTables
从网页中抓取数据。 我想知道是否有办法保留查询从中提取数据的网页的超链接。
这是一个示例查询:
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://dom.com/table, Destination:=Range("$A$1"))
.Name = "table"
.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 = xlWebFormattingRTF
.WebTables = """datatable"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
诀窍是将.WebFormatting = xlWebFormattingRTF
更改为.WebFormatting = xlWebFormattingAll
其他资源:
https://docs.microsoft.com/en-us/office/vba/api/excel.querytable.webformatting https://docs.microsoft.com/en-us/office/vba/api/excel.xlwebformatting
Name Value Description
xlWebFormattingAll 1 All formatting is imported.
xlWebFormattingNone 3 No formatting is imported.
xlWebFormattingRTF 2 Rich Text Format - compatible formatting is imported.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.