返回列表 上一主題 發帖

[發問] 請問網址可以用變數代替嗎?

[發問] 請問網址可以用變數代替嗎?

請問網址可以用變數代替嗎?
可以的話,不曉得語法該如何寫。

謝謝∼

Dear stillfish00大大,

Thanks

TOP

以下,跑了之後會發生 .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

TOP

可以 work 了,謝謝G大∼

TOP

        靜思自在 : 不要小看自己,因為人有無限的可能。
返回列表 上一主題