首页 > 解决方案 > 使用 VBA 从 Google 电子表格导入范围

问题描述

我拥有的代码是在 Google 电子表格上导入所有内容,包括行号和列标题。

如何导入特定范围的工作表?

Sub Basic_Web_Query()
With ActiveSheet.QueryTables.Add(Connection:= _
  "URL;https://docs.google.com/spreadsheets/d/11H_-UFOpNAtQbs5BNOwZZK1KBew6l-8XKmoMycWuizU/edit?usp=sharing", Destination:=Range("$A$1"))
  .Name = "q?s=goog_2"
  .FieldNames = False
  .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 = "1"
  .WebPreFormattedTextToColumns = False
  .WebConsecutiveDelimitersAsOne = True
  .WebSingleBlockTextImport = False
  .WebDisableDateRecognition = False
  .WebDisableRedirections = False
  .Refresh BackgroundQuery:=False
End With
End Sub

标签: excelvbagoogle-sheets

解决方案


推荐阅读