ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

¦³ÃöEXCEL VBA §ì¨ú¤£¨ì§¹¾ãºô§}CSV°ÝÃD

­Y¬O§Ú·Qcopy¤U¦Cºô§}¬Y¤Ñ¡B¬Y´X®aªº¸ê®Æ¡Ahttp://stocker.com.tw/
¥i§_½Ð¤j¤j¼·¤¾À°¦£¡A¦³ªþÀÉ
jak µoªí©ó 2014/3/6 11:38

©êºp,¨S¦³ª`·N¨ì,¤[µ¥¤F.
¸Õ¸Õ¬Ý
  1. <input type="text" name="StoNum" id="StoNum" style="width:100px" value="1101" onkeyup="findStoNum()">
  2. '<input type="text" name="datestart" id="datepicker" style="width:80px" value="2014-05-09" class="hasDatepicker">
  3. '<input type="submit" class="senddata" value="´£¥æ">
  4. Option Explicit
  5. Dim FormDLL As String, xDate As Date, Sh As Worksheet ', Msg As Boolean
  6. Sub Ie_Table()
  7.     Dim URL As String, A As Object, i As Integer, E As Range
  8.     Set_FormDLL
  9.     URL = "http://stocker.com.tw/"
  10.     xDate = Date - 1
  11.     If Weekday(xDate, vbMonday) > 5 Then
  12.         Do While Weekday(xDate, vbMonday) > 5
  13.         xDate = xDate - 1
  14.         Loop
  15.     End If
  16.     Set Sh = Sheets.Add                   'µ²ªGÅã¥Ü¦b·s¼Wªº¤u§@ªí
  17.     Sh.Name = Format(xDate, "yyyy-mm-dd") '©R¦W¬°¤é´Á
  18.     With CreateObject("InternetExplorer.Application")
  19.         .navigate URL
  20.         .Visible = True
  21.         For Each E In Sheets("¤U¸ü¥N¸¹¦W³æ").Range("A3", Sheets("¤U¸ü¥N¸¹¦W³æ").[A3].End(xlDown))
  22.             Do While .Busy Or .ReadyState <> 4:         Loop
  23.             With .document.getElementsByTagName("input")
  24.                 .Item("StoNum").Value = E
  25.                 .Item("datestart").Value = Format(xDate, "yyyy-mm-dd")
  26.                 For i = 0 To .Length - 1
  27.                     If .Item(i).Type = "submit" Then .Item(i).Click
  28.                 Next
  29.             End With
  30.         Do While .Busy Or .ReadyState <> 4:         Loop
  31.         Set A = .document.getElementsByTagName("TABLE")
  32.         Ep A(A.Length - 1).outerHTML
  33.         Next
  34.         .Quit
  35.     End With
  36.     Remove_FormDLL
  37. End Sub
  38. Sub Ep(S As String)
  39.     Dim D As New DataObject, E As Shape
  40.     'DataObject ª«¥ó ¦b¶i¦æÂà´«°Ê§@®É¡A°µ¬°®æ¦¡¤Æ¤å¦r¸ê®Æªº¼È¦s°Ï°ì¡C¨ä¤]¥i¥H¼È¦s©MÀx¦s¦b DataObject ªº¤å¦r¤ù¬q¬ÛÃöªº®æ¦¡¡C
  41.     '«Å§i Dim D As New DataObject '¶·¦b¤u¨ã-> ³]©w¤Þ¥Î¶µ¥Ø¥[¤J ·s¼W¤Þ¥Î Microsoft Forms 2.0 Object Library ,±M®× ¥[¤J¤@ªí³æ§Y¥i
  42.     With D
  43.         .SetText S
  44.         .PutInClipboard
  45.         With Sh.UsedRange
  46.             If .Rows.Count = 1 Then
  47.                 .Cells(1).Select
  48.             Else
  49.                 .Rows(.Rows.Count).Cells(2).Select
  50.             End If
  51.             Sh.PasteSpecial Format:="Unicode ¤å¦r"
  52.              With ActiveCell
  53.                 .Cells(2, 1) = "¤é´Á"
  54.                 .Cells(3, 1).Resize(.Parent.UsedRange.Rows.Count - .Cells(3, 1).Row) = Format(xDate, "mm/dd")
  55.             End With
  56.             
  57.         End With
  58.     End With
  59. End Sub
  60. Sub Set_FormDLL()   '·s¼W¤Þ¥Î Microsoft Forms 2.0 Object Library
  61.     On Error Resume Next
  62.     FormDLL = "FM20.DLL"
  63.     ThisWorkbook.VBProject.References.AddFromFile "C:\windows\system32\FM20.DLL"
  64.     '"C:\windows\system32\"¬O2003ª©ªº¸ô®|,2003¥H¤Wª©¥»»Ý­×§ï¸ô®|
  65. End Sub
  66. Sub Remove_FormDLL() '§R°£¤Þ¥Î Microsoft Forms 2.0 Object Library
  67.     Dim D As Object
  68.     For Each D In ThisWorkbook.VBProject.References
  69.         If UCase(D.fullpath) Like "*" & FormDLL Then
  70.             ThisWorkbook.VBProject.References.Remove D
  71.         End If
  72.     Next
  73. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-5-25 16:31 ½s¿è

¦^´_ 45# jak
  1. Sub Ie_Table()
  2. Ep A(A.Length - 1).outerHTML, E '­×§ï¤@¤U
  3. End Sub
½Æ»s¥N½X
  1. Sub Ep(S As String, Code As Range)
  2.     Dim D As New DataObject ', E As Shape
  3.     'DataObject ª«¥ó ¦b¶i¦æÂà´«°Ê§@®É¡A°µ¬°®æ¦¡¤Æ¤å¦r¸ê®Æªº¼È¦s°Ï°ì¡C¨ä¤]¥i¥H¼È¦s©MÀx¦s¦b DataObject ªº¤å¦r¤ù¬q¬ÛÃöªº®æ¦¡¡C
  4.     '«Å§i Dim D As New DataObject '¶·¦b¤u¨ã-> ³]©w¤Þ¥Î¶µ¥Ø¥[¤J ·s¼W¤Þ¥Î Microsoft Forms 2.0 Object Library ,±M®× ¥[¤J¤@ªí³æ§Y¥i
  5.     With D
  6.         .SetText S
  7.         .PutInClipboard
  8.         With Sh.UsedRange
  9.             If .Rows.Count = 1 Then
  10.                 .Cells(1).Select
  11.             Else
  12.                 .Rows(.Rows.Count).Cells(2).Select
  13.             End If
  14.             Sh.PasteSpecial Format:="Unicode ¤å¦r"
  15.              With ActiveCell
  16.                 .Cells(2, 1) = "¥N¸¹"
  17.                 .Cells(3, 1).Resize(.Parent.UsedRange.Rows.Count - .Cells(3, 1).Row) = Code
  18.             End With
  19.             
  20.         End With
  21.     End With
  22. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 47# jak
¤£¦n·N«ä,³Ìªñ±`¥Ç¿ù.46#ªºµ{¦¡½X¤w§ó·s
  1. Sub Ep(S As String, Code As Range)
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : §Ñ¥\¤£§Ñ¹L¡A§Ñ«è¤£§Ñ®¦¡C
ªð¦^¦Cªí ¤W¤@¥DÃD