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

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

¦^´_ 38# GBKEE
GBKEEª©¥D±z¦n¡A¤S¨Ó¦V±z°Q±Ð¤F¡A¦]¬°¥ý«e¤£À´¬°¤°»ò¬d¸ß¤W¥«»P¤WÂd¦~¦¨¥æ¸ê°TªºVBAµ{¦¡½X¤¤¤À§O¦³"STK_NO"»P"input stock code"¡A¤§«á¤~·Q¨ì¬O­n¥h§äºô­¶­ìÖí½X
ÁöµM¤j³¡¤À³£¬Ý¤£À´¡A¤£¹L½T¹ê¬O¤À§O¦b¤W¥«»P¤WÂd¦~¦¨¥æ¸ê°Tªººô­¶­ì©l½X¤¤§ä¨ì¤W­z¨â­Ó¦r¦ê¡A§Ú·Q³oÀ³¸Ó¬O¥²©w­n¼g¦bVBA¤¤ªºÃöÁä¦r¦ê¡A«á¨Ó¥h¬d¤F¤@¤U¤WÂdªº¤ë¦¨¥æ¸ê°T
¦³¬Ý¨ì¦h¥X¤é´ÁÄ檺¦r¦ê¡A´ú¸Õ¤F±N¦r¦ê¼g¤JVBA¡A¦ý«o·|¥X¿ù¡A¹Á¸Õ¦h¦¸Åܧ󤴵Lªk¶¶§Q°õ¦æ¡A¤£ª¾¸Ó¦p¦ó±N³o¨Ç¦r¦ê¥¿½T¦a¼g¤JVBA¡A·íµM¤W¥«ªº¤ë¦¨¥æ¸ê°T
´ú¸Õµ²ªG¤]©M¤WÂdªº¤@¼Ë¡A³£¬OµL¥\¦Óªð¡A©Ò¥H¥u¯à¦A«×¥oÂZ±z¤F¡AÀµ½Ð±z¦A¦¸½ç±Ð¡A·PÁ¡I
test.zip (17.84 KB)

¤WÂd¦~¦¨¥æ¸ê°T


¤WÂd¤ë¦¨¥æ¸ê°T

TOP

¦^´_ 43# GBKEE
«¢Åo¡IGBKEEª©¥D¡A¤S¨Ó¦V±z°Q±ÐÅo¡IÃö©ó¦b43#ªºµ{¦¡½X¦bsheet(3)ªºAÄæ®M¥Î¤W¥«­ÓªÑ¥N¸¹«á¬O¥i¦æªº¡A¦ý­Y§Ú·Q±Nºô§}§ï¦¨¤ë¦¨¥æ¸ê°T
·|¦h¤F¤@­Ó"¦~"¬d¸ßÄæ¡A¤S¸Ó¦p¦ó³]©w"¦~"ªº¬d¸ßÄæ¦ì¥i¥H¦h¬d´X¦~©O¡H¨Ò¦p­º­¶¬Oª½±µ¸õ¥X103¦~¡A¦A¿é¤JªÑ²¼¥N½X§Y¥i¬d¸ß¡A§Ú·Q±N102¦~¡B101¦~ªº¸ê®Æ
¤]¤@°_¶×¤J¡AÀ³¸Ó«ç»ò°µÅܤƩO¡H§Ú·QÃöÁä¬O¤£¬O¦b¥H¤Uªºµ{¦¡½X¡A¦]¬°¹ï¤º®eªº»yªk¤£¤Ó¤F¸Ñ¡A©Ò¥H·Q¦A¨Ó½Ð±Ð±z¤@¤U¡I
§Ú­Yª½±µ±N¤ë¦¨¥æ¸ê°Tªººô§}±a¤J¡A¥u¯à¶×¤J103¦~ªº¸ê®Æ¡A¤£ª¾¹D¬O¤£¬O¦U¦~«×ªº¤ë¦¨¥æ¸ê°T¯à¹³ªÑ²¼¥N½X¤@¼Ë¦bsheet(3)ªº¬YÄæ¦ì¿é¤J·í¦¨°j°é
´N¯à¶×¤J»Ý­nªº¸ê®Æ¡A¨Ò¦p§Ú·Q­n103¡B102¡B101¡B100¦~ªº¤ë¦¨¥æ¸ê°T¡A´N¦bsheet(3)ªºBÄæ±q¤W©¹¤Ukey¤J¡A¦A°µ¤@¨Çµ{¦¡½XªºÅܧó´N¯àÅýµ{¦¡¥h¨Ì·Ó
sheet(3)ªºBÄæ¿é¤Jªº¦~¥÷¶×¤J¤ë¦¨¥æ¸ê°T¡A¤£ª¾³o¼Ëªº·Qªk¹ï¤£¹ï¡A¦A½Ð±z«üÂI¤@µf¡IÁÂÁ¡I
¡@¡@¡@Do While .Busy Or .ReadyState <> 4:    Loop
            Set A = .Document.getelementbyid("STK_NO")
            A.Value = E
             .Document.getelementSbyNAME("login_btn")(0).Click  '«ö¤U¬d¸ß
            Do While .Busy Or .ReadyState <> 4:    Loop
            Set A = .Document.getelementsbytagname("TABLE")


¤WÂd¤ë¦¨¥æ¸ê°T





¤W¥«¤ë¦¨¥æ¸ê°T

TOP

¦^´_ 43# GBKEE
¤£¦n·N«ä¡AGBKEEª©¥D¡A½Ð°Ý¬O·j´M http://www.twse.com.tw/ch/trading/exchange/FMNPTK/FMNPTKMAIN.php³o¦r¦ê¶Ü¡H
¦]¬°§Ú¦bª©¤W·j¯Á³o¦r¦ê¬O¬dµLµ²ªGªº¡A©Ò¥H·Q¸ò±z½T»{¤@¤U¡A§Ú¤]·Q¦n¦n¾Ç²ßºô­¶«Ø¸m¤£¦P¤Wªº®t§O¦b­þ¡HÁÂÁ±z¡I

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-4-30 10:30 ½s¿è

¦^´_ 42# smart3135
WEB ¬d¸ß½Ð ª©¤W¦³³\¦h°Q½× ¥i·j´M http://www.twse.com.tw/ch/trading/exchange/FMNPTK/FMNPTKMAIN.php  ³o¦r¦ê
¤W¥«»P ¤WÂd ºô­¶ªº«Ø¸m¤£¦P
  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.twse.com.tw/ch/trading/exchange/FMNPTK/FMNPTKMAIN.php"
  7.         .Visible = True   'Åã¥Üie
  8.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  9.   End With
  10. End Sub
  11. Sub ¤W¥«¦~¦¨¥æ¸ê°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.twse.com.tw/ch/trading/exchange/FMNPTK/FMNPTKMAIN.php"
  16.     t = Time
  17.     Application.DisplayStatusBar = True
  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.     '§A¤w±N¤W¥«ªºªÑ²¼¥N¸¹,¦bSheets(3).Range("A1")©¹¤UKey¤W,°j°é¨Ì³o¸ÌªºªÑ²¼¥N¸¹¶×¤J
  22.     xPath = "D:\°]³ø¸ê®Æ"
  23.     IE_Application    '
  24.     Application.StatusBar = " "
  25.     Sheets(1).Activate
  26.     For Each E In Rng
  27.         With IE
  28.             Do While .Busy Or .ReadyState <> 4:    Loop
  29.             Set A = .Document.getelementbyid("STK_NO")
  30.             A.Value = E
  31.              .Document.getelementSbyNAME("login_btn")(0).Click  '«ö¤U¬d¸ß
  32.             Do While .Busy Or .ReadyState <> 4:    Loop
  33.             Set A = .Document.getelementsbytagname("TABLE")
  34.             xFile = xPath & "\" & E & "\HPM.txt"
  35.             MkDir_Sub xFile
  36.              With Sheets(1)
  37.                 .Cells.Clear
  38.                 For i = 1 To A(7).Rows.Length - 1
  39.                     For C = 0 To A(7).Rows(i).Cells.Length - 1
  40.                     .Cells(i, C + 1) = A(7).Rows(i).Cells(C).innertext
  41.                     Next
  42.                 Next
  43.                 .UsedRange.Sort Key1:=.Range("A2"), Order1:=xlDescending, Header:=True  '±Æ§Ç:xlDescending ( ¥Ñ¤j¦Ü¤p )
  44.                 Maketxt xFile, .UsedRange
  45.             End With
  46.             ii = ii + 1
  47.         End With
  48.         Application.StatusBar = Application.Text(Time - t, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤W¥«¦~¦¨¥æ " & ii & " ¤å¦rÀÉ"
  49.     Next
  50.     IE.Quit
  51.     Application.StatusBar = Application.Text(Time - t, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤W¥«¦~¦¨¥æ " & ii & " ¤å¦rÀÉ,  Åª¨ú§¹²¦ !! "
  52.     MsgBox "¶×¤J ¤å¦rÀÉ" & ii & " ¶O®É " & Application.Text(Time - t, ["MM¤ÀSS¬í"])
  53.     ThisWorkbook.Save
  54. End Sub
  55. Sub Maketxt(xF As String, Q As Range)   '***   Q As Range  ****
  56.     Dim fs As Object, E As Range, C As Variant
  57.     Set fs = CreateObject("Scripting.FileSystemObject")
  58.     Set fs = fs.CreateTextFile(xF, True)  '³Ð¨£¤@­ÓÀÉ®×,¦pÀɮצs¦b¥iÂл\±¼
  59.     For Each E In Q.Rows   '­×§ï³o  Q.ResultRange.Rows
  60.     C = Application.Transpose(Application.Transpose(E.Value))
  61.         C = Join(C, vbTab)
  62.         fs.WriteLine C
  63.     Next
  64.     fs.Close
  65. End Sub
  66. Sub MkDir_Sub(S As String)
  67.     Dim AR, i As Integer, xPath As String
  68.     If Dir(S) = "" Then
  69.         AR = Split(S, "\")
  70.         xPath = AR(0)
  71.         For i = 1 To UBound(AR) - 1
  72.             xPath = xPath & "\" & AR(i)
  73.             If Dir(xPath, vbDirectory) = "" Then MkDir xPath
  74.         Next
  75.     End If
  76. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 38# GBKEE
GBKEEª©¥D¦­¦w¡A§Ú¦b§ì¤W¥«­ÓªÑ¦~¦¨¥æ¸ê°T¤S¹J¨ì°ÝÃD¤F¡A­ì¥»¬O·Q§Q¥Î±z¦b37#ªº§ì¨ú¤WÂd¦~¦¨¥æªºµ{¦¡½X¨Ó­×§ï¡A¦ý«o¥X¿ù¡A¯à½Ð±z¦AÀ°¦£¬Ý¤@¤U¶Ü¡H
¥t¥~¦]¬°§Æ±æ±N¶×¤J¸ê®ÆªºEXCELªí®æ°µ¤@¨Ç­×§ï¦A¦s¤Jtxt¡A©Ò¥H§Ú¤]¦³¥Î¥ý«e§ì¨ä¥L¸ê®ÆªºVBA¨Ó´ú¸Õ¡A¦ý¦]¬°¥ý«e³sµ²ªººô¯¸¬O°ê®õÃÒ¨é¡A»Ý­nªº¸ê®Æ¥u­n±N
³Ì«áªº­ÓªÑ¥N½X³]©w¦¨°j°éÅܼơA´N¯à±N¸ê®Æ¤@­Ó¤@­ÓÂ^¨ú¤U¨Ó¡A¦ý¤W¥«¦~¦¨¥æ¸ê°Tªººô­¶¤£¬O³o¼Ëªº®æ¦¡¡A©Ò¥H¤£²M·¡¸Ó«ç»ò°µ°j°é³]©wÂ^¨ú¸ê°T
½Ð±z¦A«üÂI¤@¤U¡A¦pªG¥i¥Hªº¸Ü¡A§Æ±æ¨âºØ³£¯à¾Ç¡Aªþ¤W¨â­ÓEXCEL VBA¥H¤Î³sµ²ªº¸ê°T
test.zip (37.88 KB)

"URL;https://djinfo.cathaysec.com.tw/Z/ZC/ZCC/ZCC.DJHTM?A=2330"    >>>>>>>>>³o¬O¥ý«e§Q¥Î°ê®õÃҨ鰵ªº³sµ²ºô§}¡A¥u­n±N³Ì«á§ï¦¨°j°éÅܼƴN¥i¥H¤F

"URL;http://www.twse.com.tw/ch/trading/exchange/FMNPTK/genpage/Report201404/2330_F3_1_11.php?STK_NO=2330&myear=2014&mmon=04"
³o¬OÃÒ¥æ©Ò¤W¥«­ÓªÑ2330ªº¦~¦¨¥æ¸ê°T³sµ²¡A¤£ª¾¹D¦³¨S¦³¿ìªk¥Î°j°éÅܼưµ³sµ²

"URL;http://www.twse.com.tw/ch/trading/exchange/FMNPTK/FMNPTKMAIN.php"      >>>>>>>>>>>>>>³o¬OÃÒ¥æ©Ò¤W¥«­ÓªÑ¦~¦¨¥æ¸ê°T­º­¶


³o±i¹Ï´N¬O·Q­n§ìªºªí®æ¡A¤W­±¦³´£¨ì§Æ±æ¯à¥ý¶×¨ìEXCEL¦A¦s¨ì¤å¦rÀÉ´N¬O§Æ±æ¦~ªº¶¶§Ç¥i¥H¤Ï¹L¨Ó¡A¤]´N¬O¶V·sªº¦~«×±Æ¶V¤W­±¡A¥t¥~¸ê®Æ¦b¶×¤JEXCEL«á·|±N
(¤¸,ªÑ)¤]Åܦ¨¤@¦C¡A³o¤@¦C¤]§Æ±æ¯à§R°£

TOP

¦^´_ 40# GBKEE
ª©¥D±z¦n¡A­è­è±N¹q¸£Ãö³¬«á­«·s¶}±Ò«á¦A­«·s°õ¦æVBA¡Aµ²ªG«Ü¤£¿ù¡A¤@­Ó¥­§¡¤@¬í¦h¡A¥i¯à¤§«e§Ú¦b°õ¦æVBA®É¶}±Ò¤Ó¦h¨ä¥L³nÅé¤F

³o­Ó¬OÂ^¨ú¦~¦¨¥æ¸ê°T¡AÁÙ¦³¤@­Ó¤ë¦¨¥æ¸ê°T¡A¦]¬°¤ë¦¨¥æ¸ê°T¬O­nÂI¤ë¥÷¨Ó¿ï¾Ü¡A§Ú·|¥ý¦Û¤v°µ¬Ý¬Ý¡A¤£¦æªº¸Ü·|¦A¨Ó¦V±z°Q±Ð
¥t¥~±zªþ¤Wªº¶°«O¸ê®Æ§ÚÁÙ¨S¸Õ¡A±ß¤W·|§Q¥Î®É¶¡¨Ó¸Õ¸Õ¡A¤£¹L§Ú¦³µy·LºË¤F¤@¤U¡A¦³¬Ý¨ìINPUT BOX¡A¦]¬°§Ú¬O­n¥Î°j°é³sÄòÂ^¨ú¸ê®Æ
¤£¬O­n¥ÎINPUT BOX¿é¤J¥N½X¨ÓÂ^¨ú¸ê®Æ¡A¤]¤£»Ý­nªþÀɪº¹Ï¡A¥u»Ý­n¤å¦rÀɤº®e§Y¡A¤£ª¾¹D§Ú¬O§_¸ÑŪ¿ù»~¡A·|§Q¥Î®É¶¡¤F¸Ñ¬Ý¬Ý¡A¦A¦¸·PÁ±z¡I

TOP

¦^´_ 39# smart3135
¶]¤@­Ó¤å¦rÀɪº®É¶¡¤j¬ù­n4-5¬í¡A½T©w¦³²M²z¨t²Î¤F¡A¤£¹LÁÙ¬O«D±`ºC ?
¥i¯à¬O¶V¦Ñªºª©¥»³t«×¶V§Ö,¸Õ¸Õ2003ª©¬Ý¬Ý
¥t¥~¦³¿ìªk¹³¤§«e±N¶×¤J¸ê®ÆÅã¥Ü¦bEXCEL¥H«K³v¦æ°õ¦æ®É¥i¥H¬Ý¥XEXCEL¦p¦óÅܤơA¦p¦¹³t«×§óºC¤F.

  1. Option Explicit
  2. Sub ¶°«O¤áªÑÅv_WEB_»s¹Ï()
  3.     Dim WB As Workbook, Rng As Range
  4.     Dim Ar(), A, i As Integer, strDate As String, stkno As String, Qur As String
  5.     With CreateObject("InternetExplorer.Application")
  6.         .Navigate "http://www.tdcc.com.tw/smWeb/QryStock.jsp"
  7.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  8.         Set A = .document.All.tags("option") '¸ê®Æ¤é´Áªº¤º®e
  9.         ReDim Ar(A.Length - 1)
  10.         For i = 0 To A.Length - 1
  11.             Ar(i) = A(i).innerHTML
  12.         Next
  13.         .Quit
  14.     End With
  15.     Set WB = Workbooks.Add
  16.     With WB
  17.         .Sheets(1).Name = "¹Ïªí"
  18.         .Sheets(2).Name = "¸ê®Æ®w"
  19.     End With
  20.     stkno = InputBox("¿é¤JªÑ²¼¥N¸¹", "ªÑ²¼¥N¸¹", 2317)    '
  21.     If stkno = "" Or Len(stkno) <> 4 Or Val(stkno) = 0 Then MsgBox "ªÑ²¼¥N¸¹"
  22.     For i = 0 To UBound(Ar)
  23.         strDate = Ar(i)  '¾É¤J¤ë¥÷
  24.         Qur = "http://www.tdcc.com.tw/smWeb/QryStock.jsp?SCA_DATE=" & strDate & "&SqlMethod=StockNo&StockNo=" & stkno & "&StockName=&sub=%ACd%B8%DF"          '
  25.         With WB.Sheets(3)
  26.             If .QueryTables.Count = 0 Then
  27.                 .QueryTables.Add "URL;" & Qur, .[A1]
  28.             Else
  29.                 .QueryTables(1).Connection = "URL;" & Qur
  30.             End If
  31.             With .QueryTables(1)
  32.                 .WebSelectionType = xlSpecifiedTables
  33.                 .WebFormatting = xlWebFormattingNone
  34.                 .WebTables = "6,7,8"
  35.                 .WebPreFormattedTextToColumns = True
  36.                 .WebConsecutiveDelimitersAsOne = True
  37.                 .WebSingleBlockTextImport = False
  38.                 .WebDisableDateRecognition = False
  39.                 .WebDisableRedirections = False
  40.                 .Refresh BackgroundQuery:=False
  41.                 If Application.Count(.ResultRange) = 0 Then
  42.                     MsgBox "ªÑ²¼¥N¸¹ " & stkno & " ¿ù»~"
  43.                     WB.Close , False
  44.                     Exit Sub
  45.                 End If
  46.                 If i = 0 Then WB.Sheets(2).Cells(2, i + 1).Resize(15) = .ResultRange.Range("B6").Resize(15).Value
  47.                 WB.Sheets(2).Cells(1, i + 2) = Mid(.ResultRange.Range("A3"), 6)
  48.                 WB.Sheets(2).Cells(2, i + 2).Resize(15) = .ResultRange.Range("E6").Resize(15).Value
  49.             End With
  50.         End With
  51.     Next
  52.     With WB
  53.       Set Rng = .Sheets(2).UsedRange
  54.        With .Sheets(1)
  55.             With .ChartObjects.Add(.[B3].Left, .[B3].Top, .[B3].Resize(, 15).Width, .[B3].Resize(25).Height).Chart
  56.                 .ChartType = xlLineMarkers
  57.                 .SetSourceData Rng, xlRows
  58.                 .SeriesCollection(13).AxisGroup = 2
  59.                 .HasTitle = True
  60.                 .ChartTitle.Characters.Text = WB.Sheets(3).[A1]
  61.                 .PlotArea.Interior.ColorIndex = 23
  62.             End With
  63.         End With
  64.         .Activate
  65.     End With
  66. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 38# GBKEE
GBKEEª©¥D±z¦n¡A³o­Óµ{¦¡½X§Ú¦³¸Õ¤F¡A¥i¥H¦¨¥\¡A¤£¹L¤£ª¾¹D¬°¤°»ò¶]°_¨Ó«D±`ºC¡A¤WÂd¤½¥q²Î­p¦@663®a¡A§Ú±N¥¦¿é¤J¨ìSheets(3)ªºAÄæ
¶]¤@­Ó¤å¦rÀɪº®É¶¡¤j¬ù­n4-5¬í¡A½T©w¦³²M²z¨t²Î¤F¡A¤£¹LÁÙ¬O«D±`ºC
¥t¥~¦³¿ìªk¹³¤§«e±N¶×¤J¸ê®ÆÅã¥Ü¦bEXCEL¥H«K³v¦æ°õ¦æ®É¥i¥H¬Ý¥XEXCEL¦p¦óÅܤơA³Â·Ð±z¤F¡AÁÂÁ¡I
  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 = "G:\°]³ø¸ê®Æ"
  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 & "\HPM.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

TOP

¦^´_ 37# smart3135
¥ý¦^ÂФWÂd¤ë¦¨¥æ¸ê°T,¨Æ±¡¦£§¹¦AÄ~Äò¦^ÂЧA
  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
  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 & "\¤WÂd¤ë¦¨¥æ.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
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 35# GBKEE
©êºp Àɮפ£ª¾¹D¬°¤°»ò¤W¶Ç¥¢±Ñ ©Ò¥H¦A¤W¶Ç¤@¦¸
¶°«O¸ê®Æ.zip (74.96 KB)

TOP

        ÀR«ä¦Û¦b : ¯àµ½¥Î®É¶¡ªº¤H¡A¥²¯à´x´¤¦Û¤v§V¤Oªº¤è¦V¡C
ªð¦^¦Cªí ¤W¤@¥DÃD