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

[µo°Ý] ¥i§_¥Î°j°é©ÎÅܼƶפJ¤j¶q¸ê®Æ¡H

¦^´_ 60# GBKEE
ª©¥D©êºp¡A½Ð°Ý¤@¤U¡A§Ú±N±z´£¨Ñªºµ{¦¡½X¥N¤J«á¥X¿ù¦ì¸m¤Î¥X¿ù°T®§¤´©M¤§«e¤@¼Ë¡A¯à³Â·Ð±z¦AÀ°¦£¬Ý¤@¤U¶Ü¡H·P®¦¡I
¶°«O³Ì·s.zip (27.46 KB)
  1. Option Explicit
  2. Dim IE As Object, A As Integer
  3. Sub IE_Application()
  4.     Dim I As Integer
  5.     Set IE = CreateObject("InternetExplorer.Application")
  6.     With IE
  7.         .Navigate "http://www.tdcc.com.tw/smWeb/QryStock.jsp"
  8.         .Visible = True   '¤£Åã¥Üie
  9.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  10.         'Ū¨ú¶°«O¤áªÑÅv¤À´²ªí¬d¸ßªº¸ê®Æ¤é´ÁÁ`­Ó¼Æ
  11.         A = .document.getelementsByTagName("select")("SCA_DATE").Length - 1
  12.   End With
  13. End Sub
  14. Sub ¶°«O()
  15.     Dim Rng As Range, E As Range, x As Variant, T As Date, xPath As String, xFile As String
  16.     Dim Ea As Variant, ii As Integer
  17.     T = Time
  18.     Application.DisplayStatusBar = True
  19.     '½Ð±N¤WÂdªºªÑ²¼¥N¸¹,¦b Sheets(3).Range("A1")©¹¤UKey¤W,°j°é¨Ì³o¸ÌªºªÑ²¼¥N¸¹¶×¤J
  20.     Set Rng = ThisWorkbook.Sheets(3).Range("A:A")
  21.     If Application.Count(Rng) = 0 Then MsgBox "¨S¦³ªÑ²¼¥N¸¹": Exit Sub
  22.     Set Rng = Rng.SpecialCells(xlCellTypeConstants)
  23.     xPath = "D:\°]³ø¸ê®Æ"
  24.     IE_Application    '
  25.     Application.StatusBar = " "
  26.     For Each E In Rng
  27.         With Sheets(1)
  28.             .Activate
  29.             .Cells.Clear  '¤U¸ü¸ê®Æ¸m©ó¦¹¤u§@ªí,ÅÜ´«ªÑ²¼®É:²MªÅ
  30.         End With
  31.         For x = A - 1 To A
  32.             With IE
  33.                 .document.getelementsByTagName("select")("SCA_DATE")(x).Selected = True
  34.                                             '³o¸Ìªº¸ê®Æ¤é´Á »Ý¥Î Select ¥¦¬O¦³[¦~«×¤ë¥÷¤é´Á]ªº
  35.                  .document.getElementById("StockNo").Value = E
  36.                     .document.getelementsByTagName("INPUT")("sub").Click  '«ö¤U¬d¸ß
  37.                        '³o¸Ìªº¬d¸ß¬O<INPUT TYPE="submit" VALUE="¬d¸ß" name="sub">
  38.                 'End With
  39.                 Do While .Busy Or .readyState <> 4:    Loop
  40.                 Ep .document.getelementsByTagName("TABLE")(7).outerHTML
  41.             End With
  42.         Next x
  43.         xFile = xPath & "\" & E & "\SHD.txt"
  44.         MkDir_Sub xFile
  45.         
  46.         Maketxt xFile, Sheets(1).Range("A1").CurrentRegion, E.Value
  47.         '***·Q½Ð°Ý±zCode As StringªºCode¬O«ç»ò±a¥X­ÓªÑ½s¸¹ªº ****
  48.         'xFile(²Ä¤@­Ó¤Þ¼Æ), Sheets(1).Range("A1").CurrentRegion(²Ä¤G­Ó¤Þ¼Æ),E.Value(²Ä¤T­Ó¤Þ¼Æ)
  49.         
  50.         ii = ii + 1
  51.         Application.StatusBar = Application.Text(Time - T, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤W¥«¤ë¦¨¥æ " & ii & " ¤å¦rÀÉ"
  52.     Next E
  53.     IE.Quit
  54.     Application.StatusBar = Application.Text(Time - T, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤W¥«¤ë¦¨¥æ " & ii & " ¤å¦rÀÉ,  Åª¨ú§¹²¦ !! "
  55.     MsgBox "¶×¤J ¤å¦rÀÉ" & ii & " ¶O®É " & Application.Text(Time - T, ["MM¤ÀSS¬í"])
  56. '    ThisWorkbook.Save
  57. End Sub
  58. Sub Ep(S As String)
  59.     Dim D As New DataObject, E As Shape, FormDLL As String, Rng As Range
  60.     'DataObject ª«¥ó ¦b¶i¦æÂà´«°Ê§@®É¡A°µ¬°®æ¦¡¤Æ¤å¦r¸ê®Æªº¼È¦s°Ï°ì¡C¨ä¤]¥i¥H¼È¦s©MÀx¦s¦b DataObject ªº¤å¦r¤ù¬q¬ÛÃöªº®æ¦¡¡C
  61.     '«Å§i Dim D As New DataObject '¶·¦b¤u¨ã-> ³]©w¤Þ¥Î¶µ¥Ø¥[¤J ·s¼W¤Þ¥Î Microsoft Forms 2.0 Object Library ,±M®× ¥[¤J¤@ªí³æ§Y¥i
  62.     On Error GoTo ER
  63.     With D
  64.         .SetText S
  65.         .PutInClipboard
  66.         With Sheets(1)
  67.             .Range("a" & .Rows.Count).End(xlUp).Offset(1).Select
  68.             .PasteSpecial Format:="Unicode ¤å¦r"
  69. '            Set Rng = Selection
  70. '                Rng.Sort Key1:=Rng.Range("B2"), Order1:=xlDescending, Header:=xlYes ', _
  71.                 OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
  72.                 :=xlStroke, DataOption1:=xlSortNorma
  73.         End With
  74.     End With
  75.     Exit Sub
  76. ER:
  77.     FormDLL = "FM20.DLL"
  78.     ThisWorkbook.VBProject.References.AddFromFile "C:\windows\system32\" & FormDLL
  79.     Resume
  80. End Sub
  81. Sub Maketxt(xF As String, Q As Range, Code As String)     '±N¶×¤J¸ê®Æ¦s¤J«ü©wªºtxt
  82.           '***·Q½Ð°Ý±zCode As StringªºCode¬O«ç»ò±a¥X­ÓªÑ½s¸¹ªº ****
  83.           ' xF(±µ¦¬ªº¤Þ¼Æ¦WºÙ) As String(¦r¦ê«¬ºA), Q As Range(Rangeª«¥ó«¬ºA), Code As String(¦r¦ê«¬ºA)
  84.     Dim fs As Object, E As Range, C As Variant
  85.     Set fs = CreateObject("Scripting.FileSystemObject")
  86.     Set fs = fs.CreateTextFile(xF, True)  '³Ð¨£¤@­ÓÀÉ®×,¦pÀɮצs¦b¥iÂл\±¼
  87.     For Each E In Q.Rows
  88.         C = Application.Transpose(Application.Transpose(E.Value))
  89.         C = Join(C, vbTab)
  90.         fs.WriteLine C
  91.     Next
  92.     fs.Close
  93. End Sub
  94. Sub MkDir_Sub(S As String)
  95.     Dim AR, I As Integer, xPath As String
  96.     If Dir(S) = "" Then
  97.         AR = Split(S, "\")
  98.         xPath = AR(0)
  99.         For I = 1 To UBound(AR) - 1
  100.             xPath = xPath & "\" & AR(I)
  101.             If Dir(xPath, vbDirectory) = "" Then MkDir xPath
  102.         Next
  103.     End If
  104. End Sub
½Æ»s¥N½X

TOP

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

¦^´_ 61# smart3135
¸Ó§Ú»¡©êºp
  1. 31.        For x = A - 1 To A            
½Æ»s¥N½X
»Ý§ó¥¿
  1. For x = 0 To A
½Æ»s¥N½X
½Ð¦b«ü¥X­þ¸Ì¿ù»~.
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 62# GBKEE
ª©¥D±z¦n¡A¤£¦n·N«ä¡A§Ú¦³¸ÕµÛ±NFor x = A - 1 To A §ï¦¨For x = 0 To A¡A¤£¹L¥X¿ù°T®§©M¥X¿ù¦ì¸m¤´¬Û¦P¡A¯à¤£¯à¦A³Â·Ð±z´ú¸Õ¤@¤U©O¡H
¥t¥~¦b§ó¤§«eªº¤WÂd¦~¦¨¥æ¸ê®Æ¡A´N¬O¥Î¤ñ¸ûªº¼gªk¡A¤£¶K¤WEXCELª½±µ¼g¤JTXTªºµ{¦¡½X¡AÁöµM¦³¸ê®Æ¡A¤£¹L³Ì¤W¤è¤Ö¤F­ÓªÑ¥N¸¹©M¦WºÙ¡A¤£ª¾³o³¡¤À¯à¤£¯à
¤]Â^¨ú¨ì¸ê®Æ¨Ã¼g¤JTXT¡H©Î¬O¬O¦³¥i¥H¥ý¶K¨ìEXCEL¦A¼g¤JTXTªº¤èªk¡H¦A³Â·Ð±z¤F¡I
  1. Option Explicit
  2. Dim IE As Object, A As Integer
  3. Sub IE_Application()
  4.     Dim I As Integer
  5.     Set IE = CreateObject("InternetExplorer.Application")
  6.     With IE
  7.         .Navigate "http://www.tdcc.com.tw/smWeb/QryStock.jsp"
  8.         .Visible = True   '¤£Åã¥Üie
  9.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  10.         'Ū¨ú¶°«O¤áªÑÅv¤À´²ªí¬d¸ßªº¸ê®Æ¤é´ÁÁ`­Ó¼Æ
  11.         A = .document.getelementsByTagName("select")("SCA_DATE").Length - 1
  12.   End With
  13. End Sub
  14. Sub ¶°«O()
  15.     Dim Rng As Range, E As Range, x As Variant, T As Date, xPath As String, xFile As String
  16.     Dim Ea As Variant, ii As Integer
  17.     T = Time
  18.     Application.DisplayStatusBar = True
  19.     '½Ð±N¤WÂdªºªÑ²¼¥N¸¹,¦b Sheets(3).Range("A1")©¹¤UKey¤W,°j°é¨Ì³o¸ÌªºªÑ²¼¥N¸¹¶×¤J
  20.     Set Rng = ThisWorkbook.Sheets(3).Range("A:A")
  21.     If Application.Count(Rng) = 0 Then MsgBox "¨S¦³ªÑ²¼¥N¸¹": Exit Sub
  22.     Set Rng = Rng.SpecialCells(xlCellTypeConstants)
  23.     xPath = "D:\°]³ø¸ê®Æ"
  24.     IE_Application    '
  25.     Application.StatusBar = " "
  26.     For Each E In Rng
  27.         With Sheets(1)
  28.             .Activate
  29.             .Cells.Clear  '¤U¸ü¸ê®Æ¸m©ó¦¹¤u§@ªí,ÅÜ´«ªÑ²¼®É:²MªÅ
  30.         End With
  31.         For x = 0 To A
  32.             With IE
  33.                 .document.getelementsByTagName("select")("SCA_DATE")(x).Selected = True
  34.                                             '³o¸Ìªº¸ê®Æ¤é´Á »Ý¥Î Select ¥¦¬O¦³[¦~«×¤ë¥÷¤é´Á]ªº
  35.                  .document.getElementById("StockNo").Value = E
  36.                     .document.getelementsByTagName("INPUT")("sub").Click  '«ö¤U¬d¸ß
  37.                        '³o¸Ìªº¬d¸ß¬O<INPUT TYPE="submit" VALUE="¬d¸ß" name="sub">
  38.                 'End With
  39.                 Do While .Busy Or .readyState <> 4:    Loop
  40.                 Ep .document.getelementsByTagName("TABLE")(7).outerHTML
  41.             End With
  42.         Next x
  43.         xFile = xPath & "\" & E & "\SHD.txt"
  44.         MkDir_Sub xFile
  45.         
  46.         Maketxt xFile, Sheets(1).Range("A1").CurrentRegion, E.Value
  47.         '***·Q½Ð°Ý±zCode As StringªºCode¬O«ç»ò±a¥X­ÓªÑ½s¸¹ªº ****
  48.         'xFile(²Ä¤@­Ó¤Þ¼Æ), Sheets(1).Range("A1").CurrentRegion(²Ä¤G­Ó¤Þ¼Æ),E.Value(²Ä¤T­Ó¤Þ¼Æ)
  49.         
  50.         ii = ii + 1
  51.         Application.StatusBar = Application.Text(Time - T, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤W¥«¤ë¦¨¥æ " & ii & " ¤å¦rÀÉ"
  52.     Next E
  53.     IE.Quit
  54.     Application.StatusBar = Application.Text(Time - T, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤W¥«¤ë¦¨¥æ " & ii & " ¤å¦rÀÉ,  Åª¨ú§¹²¦ !! "
  55.     MsgBox "¶×¤J ¤å¦rÀÉ" & ii & " ¶O®É " & Application.Text(Time - T, ["MM¤ÀSS¬í"])
  56. '    ThisWorkbook.Save
  57. End Sub
  58. Sub Ep(S As String)
  59.     Dim D As New DataObject, E As Shape, FormDLL As String, Rng As Range
  60.     'DataObject ª«¥ó ¦b¶i¦æÂà´«°Ê§@®É¡A°µ¬°®æ¦¡¤Æ¤å¦r¸ê®Æªº¼È¦s°Ï°ì¡C¨ä¤]¥i¥H¼È¦s©MÀx¦s¦b DataObject ªº¤å¦r¤ù¬q¬ÛÃöªº®æ¦¡¡C
  61.     '«Å§i Dim D As New DataObject '¶·¦b¤u¨ã-> ³]©w¤Þ¥Î¶µ¥Ø¥[¤J ·s¼W¤Þ¥Î Microsoft Forms 2.0 Object Library ,±M®× ¥[¤J¤@ªí³æ§Y¥i
  62.     On Error GoTo ER
  63.     With D
  64.         .SetText S
  65.         .PutInClipboard
  66.         With Sheets(1)
  67.             .Range("a" & .Rows.Count).End(xlUp).Offset(1).Select
  68.             .PasteSpecial Format:="Unicode ¤å¦r"
  69. '            Set Rng = Selection
  70. '                Rng.Sort Key1:=Rng.Range("B2"), Order1:=xlDescending, Header:=xlYes ', _
  71.                 OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
  72.                 :=xlStroke, DataOption1:=xlSortNorma
  73.         End With
  74.     End With
  75.     Exit Sub
  76. ER:
  77.     FormDLL = "FM20.DLL"
  78.     ThisWorkbook.VBProject.References.AddFromFile "C:\windows\system32\" & FormDLL
  79.     Resume
  80. End Sub
  81. Sub Maketxt(xF As String, Q As Range, Code As String)     '±N¶×¤J¸ê®Æ¦s¤J«ü©wªºtxt
  82.           '***·Q½Ð°Ý±zCode As StringªºCode¬O«ç»ò±a¥X­ÓªÑ½s¸¹ªº ****
  83.           ' xF(±µ¦¬ªº¤Þ¼Æ¦WºÙ) As String(¦r¦ê«¬ºA), Q As Range(Rangeª«¥ó«¬ºA), Code As String(¦r¦ê«¬ºA)
  84.     Dim fs As Object, E As Range, C As Variant
  85.     Set fs = CreateObject("Scripting.FileSystemObject")
  86.     Set fs = fs.CreateTextFile(xF, True)  '³Ð¨£¤@­ÓÀÉ®×,¦pÀɮצs¦b¥iÂл\±¼
  87.     For Each E In Q.Rows
  88.         C = Application.Transpose(Application.Transpose(E.Value))
  89.         C = Join(C, vbTab)
  90.         fs.WriteLine C
  91.     Next
  92.     fs.Close
  93. End Sub
  94. Sub MkDir_Sub(S As String)
  95.     Dim AR, I As Integer, xPath As String
  96.     If Dir(S) = "" Then
  97.         AR = Split(S, "\")
  98.         xPath = AR(0)
  99.         For I = 1 To UBound(AR) - 1
  100.             xPath = xPath & "\" & AR(I)
  101.             If Dir(xPath, vbDirectory) = "" Then MkDir xPath
  102.         Next
  103.     End If
  104. End Sub
½Æ»s¥N½X
  1. Option Explicit
  2. Dim IE As Object
  3. Sub IE_Application()
  4.     Set IE = CreateObject("InternetExplorer.Application")
  5.     With IE
  6.         .Navigate "http://www.gretai.org.tw/ch/stock/statistics/monthly/st42.php"
  7.         .Visible = True   '¤£Åã¥Üie
  8.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  9.   End With
  10. End Sub
  11. Sub ¤WÂd¦~¦¨¥æ¸ê°T()
  12.     Dim E As Range, xPath As String, xFile As String, A As Object, fs As Object, F As Object, IE_URL As String
  13.     Dim i As Integer, ii As Integer, t As Date, AR(), Rng As Range, r, C, S
  14.     Set fs = CreateObject("Scripting.FileSystemObject")
  15.     IE_URL = "http://www.gretai.org.tw/ch/stock/statistics/monthly/st42.php"
  16.     t = Time
  17.     Application.DisplayStatusBar = True
  18.     '½Ð±N¤WÂdªºªÑ²¼¥N¸¹,¦b Sheets(3).Range("A1")©¹¤UKey¤W,°j°é¨Ì³o¸ÌªºªÑ²¼¥N¸¹¶×¤J
  19.     Set Rng = ThisWorkbook.Sheets(3).Range("A:A")
  20.     If Application.Count(Rng) = 0 Then MsgBox "¨S¦³ªÑ²¼¥N¸¹": Exit Sub
  21.     Set Rng = Rng.SpecialCells(xlCellTypeConstants)
  22.     xPath = "D:\°]³ø¸ê®Æ"
  23.     IE_Application    '
  24.     Application.StatusBar = " "
  25.     For Each E In Rng
  26.         With IE
  27.             Set A = .Document.getelementbyid("input_stock_code")
  28.             A.Value = E
  29.             A.ParentNode.submit
  30.             Do While .Busy Or .ReadyState <> 4:    Loop
  31.             Set A = .Document.getelementsbytagname("TABLE")
  32.             xFile = xPath & "\" & E & "\HPY.txt"
  33.             MkDir_Sub xFile
  34.             With fs.CreateTextFile(xFile, True)
  35.                 For i = 1 To A(2).Rows.Length - 1
  36.                     S = ""
  37.                     For C = 0 To A(2).Rows(i).Cells.Length - 1
  38.                         S = S & A(2).Rows(i).Cells(C).innertext & vbTab
  39.                     Next
  40.                     .WriteLine S
  41.                 Next
  42.                 .Close
  43.             End With
  44.             ii = ii + 1
  45.         End With
  46.         Application.StatusBar = Application.Text(Time - t, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤WÂd¦~¦¨¥æ " & ii & " ¤å¦rÀÉ"
  47.     Next
  48.     IE.Quit
  49.     Application.StatusBar = Application.Text(Time - t, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤WÂd¦~¦¨¥æ " & ii & " ¤å¦rÀÉ,  Åª¨ú§¹²¦ !! "
  50.     MsgBox "¶×¤J ¤å¦rÀÉ" & ii & " ¶O®É " & Application.Text(Time - t, ["MM¤ÀSS¬í"])
  51. '    ThisWorkbook.Save
  52. End Sub
  53. Sub MkDir_Sub(S As String)
  54.     Dim AR, i As Integer, xPath As String
  55.     If Dir(S) = "" Then
  56.         AR = Split(S, "\")
  57.         xPath = AR(0)
  58.         For i = 1 To UBound(AR) - 1
  59.             xPath = xPath & "\" & AR(i)
  60.             If Dir(xPath, vbDirectory) = "" Then MkDir xPath
  61.         Next
  62.     End If
  63. End Sub
  64. Sub Maketxt(xF As String, Q As QueryTable)   '±N¶×¤J¸ê®Æ¦s¤J«ü©wªºtxt
  65.     Dim fs As Object, E As Range, C As Variant
  66.     Set fs = CreateObject("Scripting.FileSystemObject")
  67.     Set fs = fs.CreateTextFile(xF, True)  '³Ð¨£¤@­ÓÀÉ®×,¦pÀɮצs¦b¥iÂл\±¼
  68.     For Each E In Q.ResultRange.Rows
  69.         C = Application.Transpose(Application.Transpose(E.Value))
  70.         C = Join(C, vbTab)
  71.         fs.WriteLine C
  72.     Next
  73.     fs.Close
  74. End Sub
½Æ»s¥N½X
µ{¦¡½X»P¸ê®Æ¤£¨¬TXT.zip (46.93 KB)

TOP

¦^´_ 63# smart3135

   
¦¨For x = 0 To A¡A¤£¹L¥X¿ù°T®§©M¥X¿ù¦ì¸m¤´¬Û¦P
§Ú´ú¸Õ¨S¥X¿ù,½Ð»¡©ú¥X¿ù°T®§©M¥X¿ù¦ì¸m.
  1. With fs.CreateTextFile(xFile, True)
  2.                 S = Split(A(0).innertext, ")")(1)
  3.                 .WriteLine Split(S, vbLf)(0) '³Ì¤W¤è¥[¤W­ÓªÑ¥N¸¹©M¦WºÙ¤F.
  4.                 For i = 1 To A(2).Rows.Length - 1
  5.                     S = ""
  6.                     For C = 0 To A(2).Rows(i).Cells.Length - 1
  7.                         S = S & A(2).Rows(i).Cells(C).innertext & vbTab
  8.                     Next
  9.                     .WriteLine S
  10.                 Next
  11.                 .Close
  12.             End With
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 64# GBKEE
ª©¥D±z¦n¡A¶°«Oµ{§Ç§Ú¦³¸ÕµÛ¦A°õ¦æ¤@¦¸¡Aµ²ªGÁÙ¬O¤@¼Ë¡A¥X¿ù°T®§¦p¹Ï¡G


¥t¥~±z´£¨Ñªºµ{¦¡½X§Ú¦³¥[¤J¤WÂd¦~¦¨¥æ¤¤¡A³Ì¤W¤è¬O¦³¼g¤J¤F¡A¤£¹L¬O¼g¤JªÅ¥Õ¸ê®Æ¡A¤£¬OªÑ²¼¥N¸¹©M¦WºÙ¡A¯à³Â·Ð±z¦A¬Ý¤@¤U¶Ü¡H
  1. Sub ¤WÂd¦~¦¨¥æ¸ê°T()
  2.     Dim E As Range, xPath As String, xFile As String, A As Object, fs As Object, F As Object, IE_URL As String
  3.     Dim i As Integer, ii As Integer, t As Date, AR(), Rng As Range, r, C, S
  4.     Set fs = CreateObject("Scripting.FileSystemObject")
  5.     IE_URL = "http://www.gretai.org.tw/ch/stock/statistics/monthly/st42.php"
  6.     t = Time
  7.     Application.DisplayStatusBar = True
  8.     '½Ð±N¤WÂdªºªÑ²¼¥N¸¹,¦b Sheets(3).Range("A1")©¹¤UKey¤W,°j°é¨Ì³o¸ÌªºªÑ²¼¥N¸¹¶×¤J
  9.     Set Rng = ThisWorkbook.Sheets(3).Range("A:A")
  10.     If Application.Count(Rng) = 0 Then MsgBox "¨S¦³ªÑ²¼¥N¸¹": Exit Sub
  11.     Set Rng = Rng.SpecialCells(xlCellTypeConstants)
  12.     xPath = "D:\°]³ø¸ê®Æ"
  13.     IE_Application    '
  14.     Application.StatusBar = " "
  15.     For Each E In Rng
  16.         With IE
  17.             Set A = .Document.getelementbyid("input_stock_code")
  18.             A.Value = E
  19.             A.ParentNode.submit
  20.             Do While .Busy Or .ReadyState <> 4:    Loop
  21.             Set A = .Document.getelementsbytagname("TABLE")
  22.             xFile = xPath & "\" & E & "\HPY.txt"
  23.             MkDir_Sub xFile
  24.             With fs.CreateTextFile(xFile, True)
  25.                 S = Split(A(0).innertext, ")")(1)
  26.                 .WriteLine Split(S, vbLf)(0) '³Ì¤W¤è¥[¤W­ÓªÑ¥N¸¹©M¦WºÙ¤F.
  27.                 For i = 1 To A(2).Rows.Length - 1
  28.                     S = ""
  29.                     For C = 0 To A(2).Rows(i).Cells.Length - 1
  30.                         S = S & A(2).Rows(i).Cells(C).innertext & vbTab
  31.                     Next
  32.                     .WriteLine S
  33.                 Next
  34.                 .Close
  35.             End With
  36.             ii = ii + 1
  37.         End With
  38.         Application.StatusBar = Application.Text(Time - t, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤WÂd¦~¦¨¥æ " & ii & " ¤å¦rÀÉ"
  39.     Next
  40.     IE.Quit
  41.     Application.StatusBar = Application.Text(Time - t, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤WÂd¦~¦¨¥æ " & ii & " ¤å¦rÀÉ,  Åª¨ú§¹²¦ !! "
  42.     MsgBox "¶×¤J ¤å¦rÀÉ" & ii & " ¶O®É " & Application.Text(Time - t, ["MM¤ÀSS¬í"])
  43. '    ThisWorkbook.Save
  44. End Sub
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ smart3135 ©ó 2014-5-22 09:35 ½s¿è

¦^´_ 64# GBKEE
ª©¥D±z¦n¡A¤µ¤Ñ§Q¥Î¤WÂd¤ë¦¨¥æ¸ê®Æªºµ{¦¡½X¨Ó°µ¤F¤@¨Ç­×¥¿¡A¤w¸g¥i¥H¶¶§QÂ^¨ú¤WÂd¦~¦¨¥æ¸ê®Æ¤F¡A¥u¬OÁÙ¦³¤@¨Ç¤p°ÝÃD¡G
1.¦h¾lªº»yªk¸Ó§R°£ªº§ÚÀ³¸Ó³£§R°£¤F¡A¤£½T©w¦³¨S¦³¦h¾l¤£¥²­nªº»yªk¨S³Q§R°£
2.¦bÂ^¨ú¸ê®Æ¶K¨ìEXCEL«á¡A¤é´Áªº³¡¤À·|Åܦ¨¤å¦r¡A½Ð¨£ªþ¹Ï¡A¤£¹Lºô­¶Åã¥Üªº¥u¬O³æ¯Âªº¤é´Á
Á|¨Ò¨Ó»¡¡Gºô­¶Åã¥Üªºªí®æ¬O4/17¡A¦ý¶×¤JEXCEL«á´N·|Åܦ¨4¤ë17¤é¡A¦Ó¼g¤J¤å¦rÀɮɫhÅܦ¨2014/4/17
§Ú¦³¸ÕµÛ¦b¶×¤JEXCEL¤§«e±N¤é´ÁÄæ¦ìªºÀx¦s®æ®æ¦¡¥ý³]©w¦¨¤å¦r¡A¤£¹L¶K¤WEXCEL«áÁÙ¬O·|³Q­×§ï®æ¦¡
§Ú§Æ±æ¼g¤J¤å¦rÀɪº¤é´Á¸ê®Æ¥u­n¤ë¤é´N¦n¡A¤]´N¬O4/17¡A¤£ª¾¹D³o³¡¤À¦³¨S¦³¿ìªk­×§ï¡H
¥t¥~¦p65#¦^ÂСA¶°«O¤á¸ê®Æªº°ÝÃDÁÙ¬O¥¼¯à¸Ñ¨M¡A¦A³Â·Ð±zÀ°¦£¬Ý¤@¤UÅo¡I·PÁ¡I

  1. Option Explicit
  2. Dim IE As Object
  3. Sub IE_Application()
  4.     If Not IE Is Nothing Then IE.Quit  '·í¬d¨ì¤WÂdªº¦~¥÷´N·|¥X²{¬dµL,¦¹IEµLªk¦A«×¬d¸ß,Ãö³¬¥¦
  5.     Set IE = CreateObject("InternetExplorer.Application")
  6.     With IE
  7.         .Navigate "http://www.gretai.org.tw/ch/stock/statistics/monthly/st42.php"
  8. '        .Visible = True   '¤£Åã¥Üie
  9.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  10.     End With
  11. End Sub
  12. Sub ¤WÂd¦~¦¨¥æ¸ê°T()
  13.     Dim Rng As Range, Rng1 As Range, E As Range, T As Date, xPath As String, xFile As String
  14.     Dim Ea As Variant, AR(), ii As Integer
  15.     T = Time
  16.     Application.DisplayStatusBar = True
  17.     '½Ð±N¤WÂdªºªÑ²¼¥N¸¹,¦b Sheets(3).Range("A1")©¹¤UKey¤W,°j°é¨Ì³o¸ÌªºªÑ²¼¥N¸¹¶×¤J
  18.     Set Rng = ThisWorkbook.Sheets(3).Range("A:A")
  19.     If Application.Count(Rng) = 0 Then MsgBox "¨S¦³ªÑ²¼¥N¸¹": Exit Sub
  20.     Set Rng = Rng.SpecialCells(xlCellTypeConstants)
  21.     xPath = "G:\°]³ø¸ê®Æ"
  22.     IE_Application
  23.     Application.StatusBar = " "
  24.     For Each E In Rng
  25.         Sheets(1).UsedRange.Clear            '¤U¸ü¸ê®Æ¸m©ó¦¹¤u§@ªí,ÅÜ´«ªÑ²¼®É:²MªÅ
  26.             With IE
  27.                  With .document.getelementbyid("input_stock_code")
  28.                     .Value = E
  29.                     .ParentNode.submit
  30.                 End With
  31.                 Do While .Busy Or .readyState <> 4:    Loop
  32.                 If Application.Count(Sheets(1).UsedRange) = 0 Then '¦¹¤u§@ªí²MªÅ®É:¤U¸ü²Ä¤@¦~«×®É
  33.                     AR = Array(0, 2)
  34. '                Else
  35. '                    AR = Array(2)
  36.                 End If
  37.                 For Each Ea In AR
  38.                     Ep .document.getElementsByTagName("TABLE")(Ea).outerHTML
  39.                 Next
  40.             End With
  41.         ii = ii + 1
  42.         xFile = xPath & "\" & E & "\HPM.txt"
  43.         MkDir_Sub xFile
  44.         Maketxt xFile, Sheets(1).UsedRange
  45.         Application.StatusBar = Application.Text(Time - T, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤WÂd" & E & "¦~¦¨¥æ " & ii & " ¤å¦rÀÉ"
  46.     Next E
  47.     IE.Quit
  48.     Application.StatusBar = Application.Text(Time - T, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤WÂd¦~¦¨¥æ " & ii & " ¤å¦rÀÉ,  Åª¨ú§¹²¦ !! "
  49.     MsgBox "¶×¤J ¤å¦rÀÉ" & ii & " ¶O®É " & Application.Text(Time - T, ["MM¤ÀSS¬í"])
  50. End Sub
  51. Sub Ep(S As String)
  52.     Dim D As New DataObject, E As Shape, FormDLL As String, Rng As Range
  53.     'DataObject ª«¥ó ¦b¶i¦æÂà´«°Ê§@®É¡A°µ¬°®æ¦¡¤Æ¤å¦r¸ê®Æªº¼È¦s°Ï°ì¡C¨ä¤]¥i¥H¼È¦s©MÀx¦s¦b DataObject ªº¤å¦r¤ù¬q¬ÛÃöªº®æ¦¡¡C
  54.     '«Å§i Dim D As New DataObject '¶·¦b¤u¨ã-> ³]©w¤Þ¥Î¶µ¥Ø¥[¤J ·s¼W¤Þ¥Î Microsoft Forms 2.0 Object Library ,±M®× ¥[¤J¤@ªí³æ§Y¥i
  55.     On Error GoTo ER
  56.     With D
  57.         .SetText S
  58.         .PutInClipboard
  59.         With Sheets(1)
  60.             .Range("a" & .Rows.Count).End(xlUp).Select
  61.             If .Range("a1") <> "" Then .Range("a" & .Rows.Count).End(xlUp).Offset(1).Select
  62.             .PasteSpecial Format:="Unicode ¤å¦r"
  63.         End With
  64.     End With
  65.     Exit Sub
  66. ER:
  67.     FormDLL = "FM20.DLL"
  68.     ThisWorkbook.VBProject.References.AddFromFile "C:\windows\system32\" & FormDLL
  69.     Resume
  70. End Sub
  71. Sub MkDir_Sub(S As String)
  72.     Dim AR, i As Integer, xPath As String
  73.     If Dir(S) = "" Then
  74.         AR = Split(S, "\")
  75.         xPath = AR(0)
  76.         For i = 1 To UBound(AR) - 1
  77.             xPath = xPath & "\" & AR(i)
  78.             If Dir(xPath, vbDirectory) = "" Then MkDir xPath
  79.         Next
  80.     End If
  81. End Sub
  82. Sub Maketxt(xF As String, Q As Range)    '±N¶×¤J¸ê®Æ¦s¤J«ü©wªºtxt
  83.     Dim fs As Object, E As Range, C As Variant
  84.     Q.Range("C1").Clear
  85.     Q.Range("A1") = Q.Range("B1") & " " & "¦~¦¨¥æ¸ê®Æ"
  86.     Q.Range("B1").Clear
  87.     Q.Rows(2).Delete
  88.     Set fs = CreateObject("Scripting.FileSystemObject")
  89.     Set fs = fs.CreateTextFile(xF, True)  '³Ð¨£¤@­ÓÀÉ®×,¦pÀɮצs¦b¥iÂл\±¼
  90.     For Each E In Q.Rows
  91.         C = Application.Transpose(Application.Transpose(E.Value))
  92.         C = Join(C, vbTab)
  93.         fs.WriteLine C
  94.     Next
  95.     fs.Close
  96. End Sub
½Æ»s¥N½X
¤WÂd¦~¦¨¥æ¸ê°T.zip (20.05 KB)

TOP

±Ò

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

¦^´_ 66# smart3135
  1. S = Split(A(0).innertext, ")")(1)
  2.                 .WriteLine Split(S, vbLf)(0) '³Ì¤W¤è¥[¤W­ÓªÑ¥N¸¹©M¦WºÙ¤F.
½Æ»s¥N½X
¶°«Oµ{§Ç§Ú¦³¸ÕµÛ¦A°õ¦æ¤@¦¸¡Aµ²ªGÁÙ¬O¤@¼Ë¡A¥X¿ù°T®§¦p¹Ï

2003ª©
½T©w¥i¥H¼g¤JªÑ²¼¥N¸¹¤Î¦WºÙ
¶°«Oµ{§Ç,¤@¼Ë½T©w¨S¦³¥X²{¿ù»~.
§A¬O¦b2007¤¤°õ¦æ¶Ü?(½Ð¦³2007ª©´ú¸Õ¤@¤U)
§Æ±æ¼g¤J¤å¦rÀɪº¤é´Á¸ê®Æ¥u­n¤ë¤é´N¦n¡A¤]´N¬O4/17
  1. Sub Maketxt(xF As String, Q As Range)    '±N¶×¤J¸ê®Æ¦s¤J«ü©wªºtxt
  2.     Dim fs As Object, E As Range, C As Variant, R As Range
  3.     With Q
  4.         .Range("C1").Clear
  5.         .Range("A1") = Q.Range("B1") & " " & "¦~¦¨¥æ¸ê®Æ"
  6.         .Range("B1").Clear
  7.         .Rows(2).Delete
  8.         .Range("H:H,F:F").NumberFormatLocal = "m/d;@"
  9.         .EntireColumn.AutoFit
  10.     End With
  11.     Set fs = CreateObject("Scripting.FileSystemObject")
  12.     Set fs = fs.CreateTextFile(xF, True)  '³Ð¨£¤@­ÓÀÉ®×,¦pÀɮצs¦b¥iÂл\±¼
  13.     For Each E In Q.Rows
  14.          C = ""
  15.          For Each R In E.Cells
  16.             C = C & IIf(C <> "", vbTab, "") & R.Text
  17.             'C = Application.Transpose(Application.Transpose(E.Value))
  18.             'C  = Join(C, vbTab)
  19.         Next
  20.         fs.WriteLine C
  21.     Next
  22.     fs.Close
  23. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 67# GBKEE
ª©¥D±z¦n¡A¦]¬°§Ú¦³Âù¨t²Î¡A¤@­Ó¬OWIN7+2007¡A¤@­Ó¬OXP+2003¡A§Ú¥­±`³£¬O¶}WIN7ªº¡A¸g§A´£¿ô¡A¤µ¤Ñ¸ÕµÛ¥Î2003¶]¤@¦¸¶°«Oµ{§Ç
µ²ªG¯uªº¥i¥H°õ¦æ¡A¤£·|¥X¿ù¡A¦ý¦b2007«o·|¥X¿ù¡A³o³¡¤À¥i¯àÁÙ­n¦A¬ã¨s¤@¤U¬°¤°»ò·|³o¼Ë
¥t¥~¼g¤J¤é´Á³¡¤À¸g±a¤J±zªºµ{¦¡½X«á¤w¥i¥¿±`¼g¤J¤é´Á¡A¦A¦¸·PÁ±z¤j¤O¨ó§U¡AÁÂÁ±z¡I

TOP

¥»©«³Ì«á¥Ñ smart3135 ©ó 2014-5-23 11:13 ½s¿è

¦^´_ 67# GBKEE
ª©¥D±z¦n¡A¸g¹L¤µ¤Ñ¦­¤W¤£Â_¨Ï¥Î2003ª©´ú¸Õ¡A²×©ó°µ¥X§Ú·Q­nªº¿é¥X¤å¦rÀɵ²ªG¡A¤£¹LÁÙ¬O¦³¨Ç°ÝÃD·|µo¥Í¡A¥ýªþ¤Wµ{¦¡½X»PªþÀÉ
¶°«O¤á-·s.zip (128.04 KB)
³o¸Ì¬O§¹¾ãªºµ{¦¡½X
  1. Option Explicit
  2. Dim IE As Object, A As Integer
  3. Sub IE_Application()
  4.     Dim I As Integer
  5.     Set IE = CreateObject("InternetExplorer.Application")
  6.     With IE
  7.         .Navigate "http://www.tdcc.com.tw/smWeb/QryStock.jsp"
  8. '        .Visible = True   '¤£Åã¥Üie
  9.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  10.         'Ū¨ú¶°«O¤áªÑÅv¤À´²ªí¬d¸ßªº¸ê®Æ¤é´ÁÁ`­Ó¼Æ
  11.         A = .document.getelementsByTagName("select")("SCA_DATE").Length - 1
  12.   End With
  13. End Sub
  14. Sub ¶°«O()
  15.     Dim Rng As Range, E As Range, x As Variant, T As Date, xPath As String, xFile As String
  16.     Dim Ea As Variant, ii As Integer, F As String, H As String, J As Integer
  17.     T = Time
  18.     Application.DisplayStatusBar = True
  19.     '½Ð±N¤WÂdªºªÑ²¼¥N¸¹,¦b Sheets(3).Range("A1")©¹¤UKey¤W,°j°é¨Ì³o¸ÌªºªÑ²¼¥N¸¹¶×¤J
  20.     Set Rng = ThisWorkbook.Sheets(3).Range("A:A")
  21.     If Application.Count(Rng) = 0 Then MsgBox "¨S¦³ªÑ²¼¥N¸¹": Exit Sub
  22.     Set Rng = Rng.SpecialCells(xlCellTypeConstants)
  23.     xPath = "E:\°]³ø¸ê®Æ"
  24.     IE_Application    '
  25.     Application.StatusBar = " "
  26.     For Each E In Rng
  27.         With Sheets(1)
  28.             .Activate
  29.             .Cells.Clear  '¤U¸ü¸ê®Æ¸m©ó¦¹¤u§@ªí,ÅÜ´«ªÑ²¼®É:²MªÅ
  30.         End With
  31.             With IE
  32.                 .document.getElementById("StockNo").Value = E
  33.                 .document.getelementsByTagName("INPUT")("sub").Click  '«ö¤U¬d¸ß
  34.                        '³o¸Ìªº¬d¸ß¬O<INPUT TYPE="submit" VALUE="¬d¸ß" name="sub">
  35.                 Do While .Busy Or .readyState <> 4:    Loop
  36.                 Ep .document.getelementsByTagName("TABLE")(5).outerHTML
  37.             End With
  38.         
  39.         For x = 0 To A
  40.             With IE
  41.                 .document.getelementsByTagName("select")("SCA_DATE")(x).Selected = True
  42.                                             '³o¸Ìªº¸ê®Æ¤é´Á »Ý¥Î Select ¥¦¬O¦³[¦~«×¤ë¥÷¤é´Á]ªº
  43.                 .document.getElementById("StockNo").Value = E
  44.                 .document.getelementsByTagName("INPUT")("sub").Click  '«ö¤U¬d¸ß
  45.                        '³o¸Ìªº¬d¸ß¬O<INPUT TYPE="submit" VALUE="¬d¸ß" name="sub">
  46.                 Do While .Busy Or .readyState <> 4:    Loop
  47.                 Ep .document.getelementsByTagName("TABLE")(6).outerHTML
  48.             End With
  49.             With IE
  50.                 .document.getelementsByTagName("select")("SCA_DATE")(x).Selected = True
  51.                                             '³o¸Ìªº¸ê®Æ¤é´Á »Ý¥Î Select ¥¦¬O¦³[¦~«×¤ë¥÷¤é´Á]ªº
  52.                 .document.getElementById("StockNo").Value = E
  53.                 .document.getelementsByTagName("INPUT")("sub").Click  '«ö¤U¬d¸ß
  54.                        '³o¸Ìªº¬d¸ß¬O<INPUT TYPE="submit" VALUE="¬d¸ß" name="sub">
  55.                 Do While .Busy Or .readyState <> 4:    Loop
  56.                 Ep .document.getelementsByTagName("TABLE")(7).outerHTML
  57.             End With
  58.         Next x
  59.         With Sheets(1)
  60.             F = .Range("a3")
  61.             J = Len(F)
  62.             If J >= 19 Then
  63.                 H = Mid(F, 1, 3)
  64.             Else
  65.                 H = Mid(F, 1, 2)
  66.             End If
  67.             .Range("a1") = E & "-" & H & " " & "¶°«O¤áªÑÅv¤À´²ªí"
  68.             .Rows("2:4").Delete
  69.         End With
  70.         xFile = xPath & "\" & E & "\SHD.txt"
  71.         MkDir_Sub xFile
  72.         Maketxt xFile, Sheets(1).UsedRange, E.Value
  73.         '***·Q½Ð°Ý±zCode As StringªºCode¬O«ç»ò±a¥X­ÓªÑ½s¸¹ªº ****
  74.         'xFile(²Ä¤@­Ó¤Þ¼Æ), Sheets(1).Range("A1").CurrentRegion(²Ä¤G­Ó¤Þ¼Æ),E.Value(²Ä¤T­Ó¤Þ¼Æ)
  75.         ii = ii + 1
  76.         Application.StatusBar = Application.Text(Time - T, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤W¥«¤ë¦¨¥æ " & ii & " ¤å¦rÀÉ"
  77.     Next E
  78.     IE.Quit
  79.     Application.StatusBar = Application.Text(Time - T, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤W¥«¤ë¦¨¥æ " & ii & " ¤å¦rÀÉ,  Åª¨ú§¹²¦ !! "
  80.     MsgBox "¶×¤J ¤å¦rÀÉ" & ii & " ¶O®É " & Application.Text(Time - T, ["MM¤ÀSS¬í"])
  81. '    ThisWorkbook.Save
  82. End Sub
  83. Sub Ep(S As String)
  84.     Dim D As New DataObject, E As Shape, FormDLL As String, Rng As Range
  85.     'DataObject ª«¥ó ¦b¶i¦æÂà´«°Ê§@®É¡A°µ¬°®æ¦¡¤Æ¤å¦r¸ê®Æªº¼È¦s°Ï°ì¡C¨ä¤]¥i¥H¼È¦s©MÀx¦s¦b DataObject ªº¤å¦r¤ù¬q¬ÛÃöªº®æ¦¡¡C
  86.     '«Å§i Dim D As New DataObject '¶·¦b¤u¨ã-> ³]©w¤Þ¥Î¶µ¥Ø¥[¤J ·s¼W¤Þ¥Î Microsoft Forms 2.0 Object Library ,±M®× ¥[¤J¤@ªí³æ§Y¥i
  87.     On Error GoTo ER
  88.     With D
  89.         .SetText S
  90.         .PutInClipboard
  91.         With Sheets(1)
  92.             .Range("a" & .Rows.Count).End(xlUp).Select
  93.             Set Rng = Selection
  94.             If Rng = 15 Then
  95.                 Rng.Offset(3).Select
  96.             Else
  97.                 Rng.Offset(2).Select
  98.             End If
  99.             .PasteSpecial Format:="Unicode ¤å¦r"
  100. '            If Selection = "" Then Selection.Offset(1).Select
  101. '            Set Rng = Selection
  102. '                Rng.Sort Key1:=Rng.Range("B2"), Order1:=xlDescending, Header:=xlYes ', _
  103.                 OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
  104.                 :=xlStroke, DataOption1:=xlSortNorma
  105.         End With
  106.     End With
  107.     Exit Sub
  108. ER:
  109.     FormDLL = "FM20.DLL"
  110.     ThisWorkbook.VBProject.References.AddFromFile "C:\windows\system32\" & FormDLL
  111.     Resume
  112. End Sub
  113. Sub Maketxt(xF As String, Q As Range, Code As String)     '±N¶×¤J¸ê®Æ¦s¤J«ü©wªºtxt
  114.           '***·Q½Ð°Ý±zCode As StringªºCode¬O«ç»ò±a¥X­ÓªÑ½s¸¹ªº ****
  115.           ' xF(±µ¦¬ªº¤Þ¼Æ¦WºÙ) As String(¦r¦ê«¬ºA), Q As Range(Rangeª«¥ó«¬ºA), Code As String(¦r¦ê«¬ºA)
  116.     Dim fs As Object, E As Range, C As Variant
  117.     Set fs = CreateObject("Scripting.FileSystemObject")
  118.     Set fs = fs.CreateTextFile(xF, True)  '³Ð¨£¤@­ÓÀÉ®×,¦pÀɮצs¦b¥iÂл\±¼
  119.     For Each E In Q.Rows
  120.         C = Application.Transpose(Application.Transpose(E.Value))
  121.         C = Join(C, vbTab)
  122.         fs.WriteLine C
  123.     Next
  124.     fs.Close
  125. End Sub
  126. Sub MkDir_Sub(S As String)
  127.     Dim AR, I As Integer, xPath As String
  128.     If Dir(S) = "" Then
  129.         AR = Split(S, "\")
  130.         xPath = AR(0)
  131.         For I = 1 To UBound(AR) - 1
  132.             xPath = xPath & "\" & AR(I)
  133.             If Dir(xPath, vbDirectory) = "" Then MkDir xPath
  134.         Next
  135.     End If
  136. End Sub
½Æ»s¥N½X
¦]¬°§Ú­nªº¤å¦rÀÉ°£¤F­ÓªÑ¥N¸¹©M¦WºÙ¤§¥~¡AÁÙ¦³¤é´Á¤]­n¤@¨Ö¼g¤J¡A©Ò¥H§Ú´N¦Û¤v¥[¤F¥H¤U³o¨ÇªF¦è
  1.             With IE
  2.                 .document.getElementById("StockNo").Value = E
  3.                 .document.getelementsByTagName("INPUT")("sub").Click  '«ö¤U¬d¸ß
  4.                        '³o¸Ìªº¬d¸ß¬O<INPUT TYPE="submit" VALUE="¬d¸ß" name="sub">
  5.                 Do While .Busy Or .readyState <> 4:    Loop
  6.                 Ep .document.getelementsByTagName("TABLE")(5).outerHTML
  7.             End With
  8.         
  9.         For x = 0 To A
  10.             With IE
  11.                 .document.getelementsByTagName("select")("SCA_DATE")(x).Selected = True
  12.                                             '³o¸Ìªº¸ê®Æ¤é´Á »Ý¥Î Select ¥¦¬O¦³[¦~«×¤ë¥÷¤é´Á]ªº
  13.                 .document.getElementById("StockNo").Value = E
  14.                 .document.getelementsByTagName("INPUT")("sub").Click  '«ö¤U¬d¸ß
  15.                        '³o¸Ìªº¬d¸ß¬O<INPUT TYPE="submit" VALUE="¬d¸ß" name="sub">
  16.                 Do While .Busy Or .readyState <> 4:    Loop
  17.                 Ep .document.getelementsByTagName("TABLE")(6).outerHTML
  18.             End With
  19.             With IE
  20.                 .document.getelementsByTagName("select")("SCA_DATE")(x).Selected = True
  21.                                             '³o¸Ìªº¸ê®Æ¤é´Á »Ý¥Î Select ¥¦¬O¦³[¦~«×¤ë¥÷¤é´Á]ªº
  22.                 .document.getElementById("StockNo").Value = E
  23.                 .document.getelementsByTagName("INPUT")("sub").Click  '«ö¤U¬d¸ß
  24.                        '³o¸Ìªº¬d¸ß¬O<INPUT TYPE="submit" VALUE="¬d¸ß" name="sub">
  25.                 Do While .Busy Or .readyState <> 4:    Loop
  26.                 Ep .document.getelementsByTagName("TABLE")(7).outerHTML
  27.             End With
½Æ»s¥N½X
1.­º¥ý²Ä¤@¬q¬O¬°¤F­nÂ^¨ú("TABLE")(5)¤~¯à¶×¤J­ÓªÑ¦WºÙ¡A©Ò¥H§Ú¥[¤F³o¨Ç»yªk¡A¥Ñ©ó­ÓªÑ¦WºÙ¥u»Ý­nÂ^¨ú¤@¦¸
    ©Ò¥H±N³o¬q»yªk¼g¦bx°j°é¤§¥~¡A¦ý¤£ª¾¹D³o¼Ëªº»yªk¥¿¤£¥¿½T
2.¦]¬°­nÂ^¨úªº¤é´Á¬O¦b("TABLE")(6)¡A©Ò¥H±N³o¬q¤]¼g¤J¡A´N¥u¬O½Æ»s("TABLE")(7)ªº§ï¦¨6¦Ó¤w¡A¤]¤£½T©w³o¼Ë¼g¨ì©³¥¿¤£¥¿½T
3.¥H¤Wµ{¦¡½X¦b2003¨Ï¥ÎF8³v¦æ°õ¦æ®É¬O¥i¥H¥¿±`ªº¡A¦ý¨Ï¥ÎF5³sÄò°õ¦æ®É¦³®É·|¥X¿ù¡A¤£µM´N¬O("TABLE")(5)©M("TABLE")(6)·|¦³¸ê®Æ­«ÂЩΪ̺|§ì
    ¥H("TABLE")(6)§ì¨ìªº¤é´Á¨Ó»¡¡A·|§ì¨ì¨â­Ó¤@¼Ëªº¤é´Á(¤é´Á¿ù»~)¡A¦ý¸ê®Æ¤º®eªº("TABLE")(7)«o¬O¤£¦Pªº(¤º®e¥¿½T)¡A¤]´N¬O¤é´Á©M¸ê®Æ¤º®e¹ï¤£¤W
    ¤£ª¾¹D¬O¤£©M§Úªº»yªk¦³°ÝÃD

¥t¥~¥ý«e¦V±z´£¹L¡A¥Î2007°õ¦æ¤W­zµ{¦¡½X®É·|¥X¿ù¡A¥X¿ù¥N½X¬°"424"¡A¥X¿ù°T®§¬°"¦¹³B»Ý­nª«¥ó"¡A§Ú¦³ÂI»¡©ú¶i¥h¬Ý¡A¦ý¯uªº¬Ý¤£¤ÓÀ´
§Ú±N»¡©ú¤º®e¦s¦¨PDF¤@°_©ñ¦bªþ¥ó¤¤¡A¥i¥Hªº¸Ü¦A³Â·Ð±z¬Ý¬Ý¬O¤£¬O¥i¥H§ä¥X¬°¤°»ò³o­Óµ{¦¡½X¨Sªk¦b2007°õ¦æªº­ì¦]¡A¦A¦¸·PÁ±z¡I

TOP

¦^´_ 69# smart3135
  1. Sub ¶°«O()
  2.     Dim Rng As Range, E As Range, x As Variant, T As Date, xPath As String, xFile As String
  3.     Dim Ea As Variant, ii As Integer, F As String, H As String, J As Integer, StockNo As Object
  4.     T = Time
  5.     Application.DisplayStatusBar = True
  6.     '½Ð±N¤WÂdªºªÑ²¼¥N¸¹,¦b Sheets(3).Range("A1")©¹¤UKey¤W,°j°é¨Ì³o¸ÌªºªÑ²¼¥N¸¹¶×¤J
  7.     Set Rng = ThisWorkbook.Sheets(3).Range("A:A")
  8.     If Application.Count(Rng) = 0 Then MsgBox "¨S¦³ªÑ²¼¥N¸¹": Exit Sub
  9.     Set Rng = Rng.SpecialCells(xlCellTypeConstants)
  10.     xPath = "D:\°]³ø¸ê®Æ"
  11.     IE_Application    '
  12.     Application.StatusBar = " "
  13.     For Each E In Rng
  14.         With Sheets(1)
  15.             .Activate
  16.             .Cells.Clear  '¤U¸ü¸ê®Æ¸m©ó¦¹¤u§@ªí,ÅÜ´«ªÑ²¼®É:²MªÅ
  17.         End With
  18.         For x = 0 To A
  19.             With IE
  20.                 .document.getelementsByTagName("select")("SCA_DATE")(x).Selected = True
  21.                                             '³o¸Ìªº¸ê®Æ¤é´Á »Ý¥Î Select ¥¦¬O¦³[¦~«×¤ë¥÷¤é´Á]ªº
  22.                 Set StockNo = .document.getElementById("StockNo")
  23.                 '¥X¿ù¥N½X¬°"424"¡A¥X¿ù°T®§¬°"¦¹³B»Ý­nª«¥ó",´Nµ¹¥¦³]¬°ª«¥ó,2007ª©¸Õ¸Õ¬Ý¬O§_¥i¦æ
  24.                 StockNo.Value = E
  25.                 .document.getelementsByTagName("INPUT")("sub").Click  '«ö¤U¬d¸ß
  26.                 Do While .Busy Or .readyState <> 4:    Loop
  27.                 If x = 0 Then Sheets(1).Cells(1) = .document.getelementsByTagName("TABLE")(5).INNERTEXT
  28.                 Ep .document.getelementsByTagName("TABLE")(6).INNERTEXT
  29.                 Ep .document.getelementsByTagName("TABLE")(7).outerHTML
  30.             End With
  31.         Next x
  32.         xFile = xPath & "\" & E & "\SHD.txt"
  33.         MkDir_Sub xFile
  34.         Maketxt xFile, Sheets(1).UsedRange, E.Value
  35.         ii = ii + 1
  36.         Application.StatusBar = Application.Text(Time - T, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤W¥«¤ë¦¨¥æ " & ii & " ¤å¦rÀÉ"
  37.     Next E
  38.     IE.Quit
  39.     Application.StatusBar = Application.Text(Time - T, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤W¥«¤ë¦¨¥æ " & ii & " ¤å¦rÀÉ,  Åª¨ú§¹²¦ !! "
  40.     MsgBox "¶×¤J ¤å¦rÀÉ" & ii & " ¶O®É " & Application.Text(Time - T, ["MM¤ÀSS¬í"])
  41. '    ThisWorkbook.Save
  42. End Sub
  43. Sub Ep(S As String)
  44.     Dim D As New DataObject, E As Shape, FormDLL As String, Rng As Range
  45.     'DataObject ª«¥ó ¦b¶i¦æÂà´«°Ê§@®É¡A°µ¬°®æ¦¡¤Æ¤å¦r¸ê®Æªº¼È¦s°Ï°ì¡C¨ä¤]¥i¥H¼È¦s©MÀx¦s¦b DataObject ªº¤å¦r¤ù¬q¬ÛÃöªº®æ¦¡¡C
  46.     '«Å§i Dim D As New DataObject '¶·¦b¤u¨ã-> ³]©w¤Þ¥Î¶µ¥Ø¥[¤J ·s¼W¤Þ¥Î Microsoft Forms 2.0 Object Library ,±M®× ¥[¤J¤@ªí³æ§Y¥i
  47.     On Error GoTo ER
  48.     With D
  49.         .SetText S
  50.         .PutInClipboard
  51.         With Sheets(1)
  52.             .Range("a" & .UsedRange.Rows.Count + 1).Select
  53.             Set Rng = Selection
  54.             .PasteSpecial Format:="Unicode ¤å¦r"
  55.         End With
  56.     End With
  57.     Exit Sub
  58. ER:
  59.     FormDLL = "FM20.DLL"
  60.     ThisWorkbook.VBProject.References.AddFromFile "C:\windows\system32\" & FormDLL
  61.     Resume
  62. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¤H¨ÆªºÁ}Ãø»PµZ¿i¡A´N¬O¤@ºØ¦ÒÅç¡C
ªð¦^¦Cªí ¤W¤@¥DÃD