- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
9#
發表於 2015-9-15 05:27
| 只看該作者
本帖最後由 GBKEE 於 2015-9-15 05:56 編輯
回復 8# espionage
我只有Ie8沒這問題, Ie8 中element 的 Length =9
請有比Ie8新版的會員,看看問題在哪裡.- Application.VBE.Windows("區域變數").Visible = True '請再加上
- Stop '程式停下來
- '如7#的圖可以看看你的 "區域變數"視窗 中 element 的 Length 是多少
複製代碼 或是- Application.Wait #12:00:05 AM# '在程式中'等候5秒
- Set element = .Document.getelementsbytagname("table") '取得網頁資料區塊
- Stop '程式停下來,看 "區域變數"視窗 中 element 的 Length 是多少
- With Sheets(1)
- .Cells.Clear
-
複製代碼 或是用WEB查詢- Sub Ex() '集保戶股權分散表_WEB查詢
- Dim Ar(), a, i As Integer, strDate As String, stkno As String, Qur As String
- With CreateObject("InternetExplorer.Application")
- .Navigate "http://www.tdcc.com.tw/smWeb/QryStock.jsp"
- Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
- Set a = .Document.ALL.tags("option") '資料日期的內容
- ReDim Ar(a.Length - 1)
- For i = 0 To a.Length - 1
- Ar(i) = a(i).innerHTML
- Next
- .Quit
- End With
- strDate = Ar(0) '導入當月日期
- Do
- strDate = InputBox(Join(Ar, vbTab), "集保戶股權分散表查詢 之 有效日期", strDate)
- If strDate = "" Then Exit Sub
-
- Loop Until IsNumeric(Application.Match(strDate, Ar, 0))
- stkno = InputBox("輸入股票代號", "股票代號", 2317) '
- If stkno = "" Then Exit Sub
- Qur = "http://www.tdcc.com.tw/smWeb/QryStock.jsp?SCA_DATE=" & strDate & "&SqlMethod=StockNo&StockNo=" & stkno & "&StockName=&sub=%ACd%B8%DF"
- With ActiveSheet
- If .QueryTables.Count = 0 Then
- .QueryTables.Add "URL;" & Qur, .[A1]
- Else
- .QueryTables(1).Connection = "URL;" & Qur
- End If
- With .QueryTables(1)
- .WebSelectionType = xlSpecifiedTables
- .WebFormatting = xlWebFormattingNone
- .WebTables = "6,7,8"
- .WebPreFormattedTextToColumns = True
- .WebConsecutiveDelimitersAsOne = True
- .WebSingleBlockTextImport = False
- .WebDisableDateRecognition = False
- .WebDisableRedirections = False
- .Refresh BackgroundQuery:=False
- End With
- End With
- End Sub
複製代碼 |
|