標題:
[發問]
請問網址可以用變數代替嗎?
[打印本頁]
作者:
cji3cj6xu6
時間:
2013-7-24 10:37
標題:
請問網址可以用變數代替嗎?
請問網址可以用變數代替嗎?
可以的話,不曉得語法該如何寫。
謝謝∼
作者:
stillfish00
時間:
2013-7-24 10:45
回復
1#
cji3cj6xu6
Dim 變數 as string
變數 = "http://forum.twbts.com/"
複製代碼
作者:
cji3cj6xu6
時間:
2013-7-24 11:27
Dear stillfish00大大,
Thanks
作者:
cji3cj6xu6
時間:
2013-7-24 13:42
以下,跑了之後會發生 .Refresh BackgroundQuery:=False 錯誤,但若是直接將網址放上則ok,請問要如何修改,
謝謝∼
Dim WebAddress as string
WebAddress = "http://tw.stock.yahoo.com/q/q?s=1101"
Range("a2").Select
'With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://tw.stock.yahoo.com/q/q?s=" & [a1] & "", Destination:=Selection) '新增查詢
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;WebAddress", 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
作者:
GBKEE
時間:
2013-7-24 14:13
回復
4#
cji3cj6xu6
Option Explicit
Sub EX()
Dim WebAddress As String
WebAddress = "http://tw.stock.yahoo.com/q/q?s=1101"
Range("a2").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & WebAddress, 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
複製代碼
作者:
cji3cj6xu6
時間:
2013-7-24 14:24
可以 work 了,謝謝G大∼
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)