½Ð°Ý¦p¦ó¥Î MSXML2.XMLHTTP ®» »OÆWÃÒ¨é¥æ©ö©Ò ӪѤ릨¥æ¸ê°T
- ©«¤l
- 161
- ¥DÃD
- 26
- ºëµØ
- 0
- ¿n¤À
- 187
- ÂI¦W
- 0
- §@·~¨t²Î
- xp
- ³nÅ骩¥»
- office 2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- TW
- µù¥U®É¶¡
- 2011-1-2
- ³Ì«áµn¿ý
- 2022-2-16
|
½Ð°Ý¦p¦ó¥Î MSXML2.XMLHTTP ®» »OÆWÃÒ¨é¥æ©ö©Ò ӪѤ릨¥æ¸ê°T
½Ð°Ý¦p¦ó¥Î MSXML2.XMLHTTP ®»
»OÆWÃÒ¨é¥æ©ö©Ò ӪѤ릨¥æ¸ê°T
http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/STOCK_DAYMAIN.php
ªº¸ê®Æ
ÁÂÁÂ
¨Ò¦p¡G
http://social.msdn.microsoft.com/Forums/en-US/bd0ee306-7bb5-4ce4-8341-edd9475f84ad/excel-2007-use-vba-to-download-save-csv-from-url?forum=isvvba |
|
|
|
|
|
|
- ©«¤l
- 161
- ¥DÃD
- 26
- ºëµØ
- 0
- ¿n¤À
- 187
- ÂI¦W
- 0
- §@·~¨t²Î
- xp
- ³nÅ骩¥»
- office 2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- TW
- µù¥U®É¶¡
- 2011-1-2
- ³Ì«áµn¿ý
- 2022-2-16
|
¦^´_ 2# GBKEE
ÁÂÁÂ G ¤j
¦A½Ð°Ý xml.ResponseBody ¥i¥Hª½±µ¶K¦b¤u§@ªí¶Ü
§ä¤F«Ü¤[³£§ä¤U¨ì ÁÂÁ |
|
|
|
|
|
|
- ©«¤l
- 161
- ¥DÃD
- 26
- ºëµØ
- 0
- ¿n¤À
- 187
- ÂI¦W
- 0
- §@·~¨t²Î
- xp
- ³nÅ骩¥»
- office 2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- TW
- µù¥U®É¶¡
- 2011-1-2
- ³Ì«áµn¿ý
- 2022-2-16
|
¦^´_ 4# GBKEE
ÁÂÁÂ G ¤j
§Ún°µÓªÑ¦¨¥æ¶q¦³µL¼É¶q¡Aµ{¦¡¥in¬ã¨s¤@¬q®É¶¡¡A¦A½Ð±Ð G ¤j
«D±`·P¿E |
|
|
|
|
|
|
- ©«¤l
- 161
- ¥DÃD
- 26
- ºëµØ
- 0
- ¿n¤À
- 187
- ÂI¦W
- 0
- §@·~¨t²Î
- xp
- ³nÅ骩¥»
- office 2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- TW
- µù¥U®É¶¡
- 2011-1-2
- ³Ì«áµn¿ý
- 2022-2-16
|
¦^´_ 4# GBKEE
G ¤j ±z¦n
§Ú·Q±N¤u§@ªí1ªºÓªÑ§ä¥X¥X¶qªÑ ©ñ¦A¤u§@ªí2¤¤
¬O§_¥Î¤Ó¦h¸ê·½¤F ¥X¤F¦p¤U¹Ïªº¿ù»~
¬°¤°»ò set CreateObject("InternetExplorer.Application") = Nothing ¤£¥i¥Î
½Ð±Ð G ¤j¦p¦óקï
ÁÂÁÂ- Option Explicit
- Sub Index()
- Dim i As Integer, I2 As Integer
- Dim x, y, XX, YY, ZZ
- Dim k
- Const AA As Integer = 5
- ¤u§@ªí3.Activate
- '¤u§@ªí3.Select
- If Int(Split(Date, "/")(2)) < 6 Then '¬O¤£¹L6¤Ñ¹Bºâ¡A¤£¹L¥[¤W¤ë¥÷
- Application.ScreenUpdating = False
- With ¤u§@ªí1
- k = 2
- For i = 2 To .Range("A" & .Rows.Count).End(xlUp).Row
- I2 = .Cells(i, 1).Value
- Debug.Print I2
- Call Ex_2(Split(Date, "/")(0) & Format((Split(Date, "/")(1) - 1), "00"), Split(Date, "/")(0) & Format((Split(Date, "/")(1)), "00"), I2)
-
- y = ¤u§@ªí3.Range("J" & ¤u§@ªí3.Rows.Count).End(xlUp).Row - 3 - 1 ' ³o¤ë¥÷n¥Îªº¥§¡¼Æ
- x = AA - y
- YY = ¤u§@ªí3.Range("J" & ¤u§@ªí3.Rows.Count).End(xlUp).Row - y
- XX = ¤u§@ªí3.Range("A" & ¤u§@ªí3.Rows.Count).End(xlUp).Row - x + 1
- ZZ = (WorksheetFunction.Sum(¤u§@ªí3.Cells(YY, 11).Resize(y)) + WorksheetFunction.Sum(¤u§@ªí3.Cells(XX, 2).Resize(x))) / AA
- On Error Resume Next
- If ¤u§@ªí3.Cells(¤u§@ªí3.Range("J" & ¤u§@ªí3.Rows.Count).End(xlUp).Row, 11) > ZZ * 5 Then
- ¤u§@ªí2.Cells(k, 1).Resize(, 2).Value = .Cells(i, 1).Resize(, 2).Value
- k = k + 1
- Debug.Print k
- End If
-
-
- Next
- End With
- Application.ScreenUpdating = True
- Else
- With ¤u§@ªí1
- ''''''''¥¼´ú¸Õ
- For i = 2 To .Range("A" & .Rows.Count).End(xlUp).Row
-
- Call Ex_1(Split(Date, "/")(0) & Format((Split(Date, "/")(1)), "00"), I2)
- Next
- '''''''¥¼´ú¸Õ
- End With
- End If
- End Sub
- Sub Ex_1(SS As String, MM As Integer)
- Dim i As Integer, S As Integer, k As Integer, A As Object, II, j
- ' ¤u§@ªí3.Select
- With CreateObject("InternetExplorer.Application")
- ' .Visible = True
- .Navigate "http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/STOCK_DAY_print.php?genpage=genpage/Report" & SS & "/" & SS & "_F3_1_8_" & MM & ".php&type=list"
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- Ep .document.getElementsByTagName("table")(1).outerHTML
- On Error Resume Next
- .Quit 'Ãö³¬ºô¶
- End With
-
- End Sub
- Sub Ex_2(SS As String, SS2 As String, MM As Integer)
- Dim i As Integer, S As Integer, k As Integer, A As Object, II, j
- ' ¤u§@ªí3.Select
- With CreateObject("InternetExplorer.Application")
- ' .Visible = True
- .Navigate "http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/STOCK_DAY_print.php?genpage=genpage/Report" & SS & "/" & SS & "_F3_1_8_" & MM & ".php&type=list"
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- Ep .document.getElementsByTagName("table")(1).outerHTML
- On Error Resume Next
- .Quit 'Ãö³¬ºô¶
- End With
- With CreateObject("InternetExplorer.Application")
- ' .Visible = True
- .Navigate "http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/STOCK_DAY_print.php?genpage=genpage/Report" & SS2 & "/" & SS2 & "_F3_1_8_" & MM & ".php&type=list"
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- Ep2 .document.getElementsByTagName("table")(1).outerHTML
- On Error Resume Next
- .Quit 'Ãö³¬ºô¶
- End With
- End Sub
- Sub Ep(S As String)
- Dim D As New DataObject
- 'DataObject ª«¥ó ¦b¶i¦æÂà´«°Ê§@®É¡A°µ¬°®æ¦¡¤Æ¤å¦r¸ê®Æªº¼È¦s°Ï°ì¡C¨ä¤]¥i¥H¼È¦s©MÀx¦s¦b DataObject ªº¤å¦r¤ù¬q¬ÛÃöªº®æ¦¡¡C
- '«Å§i Dim D As New DataObject '¶·¦b¤u¨ã-> ³]©w¤Þ¥Î¶µ¥Ø¥[¤J ·s¼W¤Þ¥Î Microsoft Forms 2.0 Object Library ,©Î©ó±M®× ¥[¤J¤@ªí³æ§Y¥i
- With D
- .SetText S
- .PutInClipboard
- With ActiveSheet
- .UsedRange.Clear
- .Range("a1").Select
- .PasteSpecial Format:="Unicode ¤å¦r"
- End With
- End With
- End Sub
- Sub Ep2(S As String)
- Dim D As New DataObject
- 'DataObject ª«¥ó ¦b¶i¦æÂà´«°Ê§@®É¡A°µ¬°®æ¦¡¤Æ¤å¦r¸ê®Æªº¼È¦s°Ï°ì¡C¨ä¤]¥i¥H¼È¦s©MÀx¦s¦b DataObject ªº¤å¦r¤ù¬q¬ÛÃöªº®æ¦¡¡C
- '«Å§i Dim D As New DataObject '¶·¦b¤u¨ã-> ³]©w¤Þ¥Î¶µ¥Ø¥[¤J ·s¼W¤Þ¥Î Microsoft Forms 2.0 Object Library ,©Î©ó±M®× ¥[¤J¤@ªí³æ§Y¥i
- With D
- .SetText S
- .PutInClipboard
- With ActiveSheet
- ' .UsedRange.Clear
- .Range("j1").Select
- .PasteSpecial Format:="Unicode ¤å¦r"
- End With
- End With
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|
- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¦^´_ 6# wufonna
Set CreateObject("InternetExplorer.Application")=Nothing
¤£¬OÅܼƬO¤@Ó¹ê»Úªºª«¥ó.
Nothing ÃöÁä¦r¬O¥Î¨Ó±N¤@Óª«¥óÅܼƱq¤@Ó¹ê»Úªºª«¥óùؤÀÂ÷¶}¨Ó¡C¨Ï¥Î Set ³¯z¦¡¥i«ü©w Nothing µ¹ª«¥óÅܼơC
קï¬Ý¬Ý- Option Explicit
- Dim IE As Object '«Å§i¬°³o¼Ò²Õªº¨p¥ÎÅܼÆ(³o¼Ò²Õ¤¤ªºµ{§Ç¥i©I¥sªºÅܼÆ)
- Sub Index()
- Dim i As Integer, I2 As Integer
- Dim x, y, XX, YY, ZZ
- Dim k
- Set IE = CreateObject("InternetExplorer.Application")
- Const AA As Integer = 5
- ¤u§@ªí3.Activate
- '¤u§@ªí3.Select
- With ¤u§@ªí1
- ''''''''¥¼´ú¸Õ
- For i = 2 To .Range("A" & .Rows.Count).End(xlUp).Row
- Call Ex_1(Split(Date, "/")(0) & Format((Split(Date, "/")(1)), "00"), I2)
- Next
- '''''''¥¼´ú¸Õ
- End With
- End If
- IE.Quit '¦bSub Index() µ{¦¡µ²§ô«eÃö³¬ºô¶
- End Sub
- Sub Ex_1(SS As String, MM As Integer)
- Dim i As Integer, S As Integer, k As Integer, A As Object, II, j
- ' ¤u§@ªí3.Select
- With IE
- ' .Visible = True
- On Error Resume Next
- .Navigate "http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/STOCK_DAY_print.php?genpage=genpage/Report" & SS & "/" & SS & "_F3_1_8_" & MM & ".php&type=list"
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- Ep .document.getElementsByTagName("table")(1).outerHTML
- ' .Quit 'Ãö³¬ºô¶
- End With
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|
- ©«¤l
- 161
- ¥DÃD
- 26
- ºëµØ
- 0
- ¿n¤À
- 187
- ÂI¦W
- 0
- §@·~¨t²Î
- xp
- ³nÅ骩¥»
- office 2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- TW
- µù¥U®É¶¡
- 2011-1-2
- ³Ì«áµn¿ý
- 2022-2-16
|
¥»©«³Ì«á¥Ñ wufonna ©ó 2014-10-4 11:39 ½s¿è
¦^´_ 7# GBKEE
G ¤j¤j ±z¦n
§Ú§ï¤Fµ{¦¡ °õ¦æ¤F¦p¤U¿ù»~
½Ð°Ý¦p¦ó§ï¶i ÁÂÁÂ- Option Explicit
- Dim IE As Object '«Å§i¬°³o¼Ò²Õªº¨p¥ÎÅܼÆ(³o¼Ò²Õ¤¤ªºµ{§Ç¥i©I¥sªºÅܼÆ)
- Sub Index()
- Dim i As Integer, I2 As Integer
- Dim x, y, XX, YY, ZZ
- Dim k
- Set IE = CreateObject("InternetExplorer.Application")
- Const AA As Integer = 5
- ¤u§@ªí3.Activate
- '¤u§@ªí3.Select
- If Int(Split(Date, "/")(2)) < 6 Then '¬O¤£¹L6¤Ñ¹Bºâ¡A¤£¹L¥[¤W¤ë¥÷
- Application.ScreenUpdating = False
- With ¤u§@ªí1
- k = 2
- For i = 2 To .Range("A" & .Rows.Count).End(xlUp).Row
- I2 = .Cells(i, 1).Value
- Debug.Print I2
- Call Ex_2(Split(Date, "/")(0) & Format((Split(Date, "/")(1) - 1), "00"), Split(Date, "/")(0) & Format((Split(Date, "/")(1)), "00"), I2)
-
- y = ¤u§@ªí3.Range("J" & ¤u§@ªí3.Rows.Count).End(xlUp).Row - 3 - 1 ' ³o¤ë¥÷n¥Îªº¥§¡¼Æ
- x = AA - y
- YY = ¤u§@ªí3.Range("J" & ¤u§@ªí3.Rows.Count).End(xlUp).Row - y
- XX = ¤u§@ªí3.Range("A" & ¤u§@ªí3.Rows.Count).End(xlUp).Row - x + 1
- ZZ = (WorksheetFunction.Sum(¤u§@ªí3.Cells(YY, 11).Resize(y)) + WorksheetFunction.Sum(¤u§@ªí3.Cells(XX, 2).Resize(x))) / AA
- On Error Resume Next
- If ¤u§@ªí3.Cells(¤u§@ªí3.Range("J" & ¤u§@ªí3.Rows.Count).End(xlUp).Row, 11) > ZZ * 5 Then
- ¤u§@ªí2.Cells(k, 1).Resize(, 2).Value = .Cells(i, 1).Resize(, 2).Value
- k = k + 1
- Debug.Print k
- End If
-
-
- Next
- End With
- Application.ScreenUpdating = True
- Else
- With ¤u§@ªí1
- ''''''''¥¼´ú¸Õ
- For i = 2 To .Range("A" & .Rows.Count).End(xlUp).Row
-
- Call Ex_1(Split(Date, "/")(0) & Format((Split(Date, "/")(1)), "00"), I2)
- Next
- '''''''¥¼´ú¸Õ
- End With
- End If
- IE.Quit '¦bSub Index() µ{¦¡µ²§ô«eÃö³¬ºô¶
- End Sub
- Sub Ex_1(SS As String, MM As Integer)
- Dim i As Integer, S As Integer, k As Integer, A As Object, II, j
- ' ¤u§@ªí3.Select
- With IE
- ' .Visible = True
- .Navigate "http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/STOCK_DAY_print.php?genpage=genpage/Report" & SS & "/" & SS & "_F3_1_8_" & MM & ".php&type=list"
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- Ep .document.getElementsByTagName("table")(1).outerHTML
- On Error Resume Next
- .Quit 'Ãö³¬ºô¶
- End With
-
- End Sub
- Sub Ex_2(SS As String, SS2 As String, MM As Integer)
- Dim i As Integer, S As Integer, k As Integer, A As Object, II, j
- ' ¤u§@ªí3.Select
- With IE
- ' .Visible = True
- .Navigate "http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/STOCK_DAY_print.php?genpage=genpage/Report" & SS & "/" & SS & "_F3_1_8_" & MM & ".php&type=list"
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- Ep .document.getElementsByTagName("table")(1).outerHTML
- ' On Error Resume Next
- .Quit 'Ãö³¬ºô¶
- End With
- With IE
- ' .Visible = True
- .Navigate "http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/STOCK_DAY_print.php?genpage=genpage/Report" & SS2 & "/" & SS2 & "_F3_1_8_" & MM & ".php&type=list"
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- Ep2 .document.getElementsByTagName("table")(1).outerHTML
- ' On Error Resume Next
- .Quit 'Ãö³¬ºô¶
- End With
- End Sub
- Sub Ep(S As String)
- Dim D As New DataObject
- 'DataObject ª«¥ó ¦b¶i¦æÂà´«°Ê§@®É¡A°µ¬°®æ¦¡¤Æ¤å¦r¸ê®Æªº¼È¦s°Ï°ì¡C¨ä¤]¥i¥H¼È¦s©MÀx¦s¦b DataObject ªº¤å¦r¤ù¬q¬ÛÃöªº®æ¦¡¡C
- '«Å§i Dim D As New DataObject '¶·¦b¤u¨ã-> ³]©w¤Þ¥Î¶µ¥Ø¥[¤J ·s¼W¤Þ¥Î Microsoft Forms 2.0 Object Library ,©Î©ó±M®× ¥[¤J¤@ªí³æ§Y¥i
- With D
- .SetText S
- .PutInClipboard
- With ActiveSheet
- .UsedRange.Clear
- .Range("a1").Select
- .PasteSpecial Format:="Unicode ¤å¦r"
- End With
- End With
- End Sub
- Sub Ep2(S As String)
- Dim D As New DataObject
- 'DataObject ª«¥ó ¦b¶i¦æÂà´«°Ê§@®É¡A°µ¬°®æ¦¡¤Æ¤å¦r¸ê®Æªº¼È¦s°Ï°ì¡C¨ä¤]¥i¥H¼È¦s©MÀx¦s¦b DataObject ªº¤å¦r¤ù¬q¬ÛÃöªº®æ¦¡¡C
- '«Å§i Dim D As New DataObject '¶·¦b¤u¨ã-> ³]©w¤Þ¥Î¶µ¥Ø¥[¤J ·s¼W¤Þ¥Î Microsoft Forms 2.0 Object Library ,©Î©ó±M®× ¥[¤J¤@ªí³æ§Y¥i
- With D
- .SetText S
- .PutInClipboard
- With ActiveSheet
- ' .UsedRange.Clear
- .Range("j1").Select
- .PasteSpecial Format:="Unicode ¤å¦r"
- End With
- End With
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|
- ©«¤l
- 161
- ¥DÃD
- 26
- ºëµØ
- 0
- ¿n¤À
- 187
- ÂI¦W
- 0
- §@·~¨t²Î
- xp
- ³nÅ骩¥»
- office 2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- TW
- µù¥U®É¶¡
- 2011-1-2
- ³Ì«áµn¿ý
- 2022-2-16
|
¦^´_ 7# GBKEE
ÁÂÁÂ G ¤j¤j
µ{¦¡¦p¹Ïªº¿ù»~
§Úµù¸Ñ¤F°Æµ{¦¡ªº
' .Quit 'Ãö³¬ºô¶
¥Dµ{¦¡¥[ Set IE = Nothing
´N¥i¤F
«D±`·PÁÂ G ¤j¤j
§Ú¦A§ï¬Ý¬Ý ¤£À´¦A½Ð±Ð ¤j¤j
^_^ |
|
|
|
|
|
|