- 帖子
- 14
- 主題
- 0
- 精華
- 0
- 積分
- 58
- 點名
- 0
- 作業系統
- Win10
- 軟體版本
- Office 2016
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2011-7-20
- 最後登錄
- 2020-3-9
|
3#
發表於 2018-1-6 22:18
| 只看該作者
隨便寫寫,參考看看
Sub 巨集1()
'
' 巨集1 巨集
'
'
Dim S As String
Dim E As String
Dim B As String
Dim P As String
S = "ctl00$ContentPlaceHolder1$startText="
E = "ctl00$ContentPlaceHolder1$endText="
B = "ctl00$ContentPlaceHolder1$submitBut=""查詢"""
P = Format(InputBox("請輸入起始日期", "參數輸入", Date), "YYYY/MM/DD")
S = S + P
P = ""
P = Format(InputBox("請輸入結束日期", "參數輸入", Date), "YYYY/MM/DD")
E = E + P
Application.CutCopyMode = False
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://www.cnyes.com/twstock/ps_historyprice.aspx?pageTypeHidden=1 & code=2330" & S & E & B, _
Destination:=Range("$A$1"))
' .CommandType = 0
.Name = "ps_historyprice.aspx?code=2330"
.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 = "1"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub |
|