Sub readUrl()
Dim url As String
Dim mySheet As String
url = "http://typhoon.yahoo.co.jp/weather/jp/earthquake/list/"
ActiveSheet.Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:="URL;" & url, Destination:=ActiveSheet.Range("A1"))
.Name = "test"
.FieldNames = True
.RowNumbers = False
.Refresh BackgroundQuery:=False
.RefreshPeriod = 0
.RefreshOnFileOpen = False
.PreserveFormatting = True
.AdjustColumnWidth = True
.FillAdjacentFormulas = False
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = True
.Refresh
.Parent.Names(.Name).Delete
End With
End Sub
2012年3月28日水曜日
vbaを使ってwebページを取り込むサンプル
ラベル:
vba
登録:
コメントの投稿 (Atom)

メリットは手軽にwebを読み込み、後は好きなように処理すれば良い。
返信削除デメリットと言えば、読み込み先のページのレイアウトが更新されたらプログラムも更新しなければならないか…