- 帖子
- 231
- 主題
- 55
- 精華
- 0
- 積分
- 293
- 點名
- 0
- 作業系統
- winxp
- 軟體版本
- office2003
- 閱讀權限
- 20
- 性別
- 男
- 來自
- KEELUNG
- 註冊時間
- 2010-7-24
- 最後登錄
- 2018-8-28
|
10#
發表於 2011-10-17 09:32
| 只看該作者
版主大大你好:
小弟對透過EXCEL取得網頁資料,
一直深深感到興趣但是無法領會及突破困境。
現想借用此板及板主大大提供的語法。
並取得此網頁的指定位置內容如下:
一、
網址:http://tw.stock.yahoo.com/d/s/company_1102.html
二、
取得此網頁的資料表為
獲 利 能 力 (100第2季) 最新四季每股盈餘 最近四年每股盈餘
三、
小弟有試著直接將下列語法的網址更正
如上的網址但是無法成功。
能請版主大大指點小弟。
感恩大大:
Sub 新增查詢()
Range("A1") = "2610" '股票代號
Range("A3").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://tw.stock.yahoo.com/q/q?s=" & Range("a1"), Destination:=Selection) '新增查詢
.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 = "6"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
.Name = .ResultRange.Cells(3, 1)
End With
End Sub
'***** 已新增後查詢後 可修改A1的股票代號 查詢 *****
Sub 更新查詢()
With Range("A3").QueryTable
.Connection = "URL;http://tw.stock.yahoo.com/q/q?s=" & Range("a1") '股票代號在[A1]
.Refresh BackgroundQuery:=False
.Name = .ResultRange.Cells(3, 1)
End With
End Sub |
|