有關EXCEL VBA 抓取不到完整網址CSV問題
- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
抱歉,沒有注意到,久等了.
試試看- <input type="text" name="StoNum" id="StoNum" style="width:100px" value="1101" onkeyup="findStoNum()">
- '<input type="text" name="datestart" id="datepicker" style="width:80px" value="2014-05-09" class="hasDatepicker">
- '<input type="submit" class="senddata" value="提交">
- Option Explicit
- Dim FormDLL As String, xDate As Date, Sh As Worksheet ', Msg As Boolean
- Sub Ie_Table()
- Dim URL As String, A As Object, i As Integer, E As Range
- Set_FormDLL
- URL = "http://stocker.com.tw/"
- xDate = Date - 1
- If Weekday(xDate, vbMonday) > 5 Then
- Do While Weekday(xDate, vbMonday) > 5
- xDate = xDate - 1
- Loop
- End If
- Set Sh = Sheets.Add '結果顯示在新增的工作表
- Sh.Name = Format(xDate, "yyyy-mm-dd") '命名為日期
- With CreateObject("InternetExplorer.Application")
- .navigate URL
- .Visible = True
- For Each E In Sheets("下載代號名單").Range("A3", Sheets("下載代號名單").[A3].End(xlDown))
- Do While .Busy Or .ReadyState <> 4: Loop
- With .document.getElementsByTagName("input")
- .Item("StoNum").Value = E
- .Item("datestart").Value = Format(xDate, "yyyy-mm-dd")
- For i = 0 To .Length - 1
- If .Item(i).Type = "submit" Then .Item(i).Click
- Next
- End With
- Do While .Busy Or .ReadyState <> 4: Loop
- Set A = .document.getElementsByTagName("TABLE")
- Ep A(A.Length - 1).outerHTML
- Next
- .Quit
- End With
- Remove_FormDLL
- End Sub
- Sub Ep(S As String)
- Dim D As New DataObject, E As Shape
- 'DataObject 物件 在進行轉換動作時,做為格式化文字資料的暫存區域。其也可以暫存和儲存在 DataObject 的文字片段相關的格式。
- '宣告 Dim D As New DataObject '須在工具-> 設定引用項目加入 新增引用 Microsoft Forms 2.0 Object Library ,專案 加入一表單即可
- With D
- .SetText S
- .PutInClipboard
- With Sh.UsedRange
- If .Rows.Count = 1 Then
- .Cells(1).Select
- Else
- .Rows(.Rows.Count).Cells(2).Select
- End If
- Sh.PasteSpecial Format:="Unicode 文字"
- With ActiveCell
- .Cells(2, 1) = "日期"
- .Cells(3, 1).Resize(.Parent.UsedRange.Rows.Count - .Cells(3, 1).Row) = Format(xDate, "mm/dd")
- End With
-
- End With
- End With
- End Sub
- Sub Set_FormDLL() '新增引用 Microsoft Forms 2.0 Object Library
- On Error Resume Next
- FormDLL = "FM20.DLL"
- ThisWorkbook.VBProject.References.AddFromFile "C:\windows\system32\FM20.DLL"
- '"C:\windows\system32\"是2003版的路徑,2003以上版本需修改路徑
- End Sub
- Sub Remove_FormDLL() '刪除引用 Microsoft Forms 2.0 Object Library
- Dim D As Object
- For Each D In ThisWorkbook.VBProject.References
- If UCase(D.fullpath) Like "*" & FormDLL Then
- ThisWorkbook.VBProject.References.Remove D
- End If
- Next
- End Sub
複製代碼 |
|
|
|
|
|
|
|