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

[µo°Ý] vba¦Û°ÊÀx¦sºô­¶ÀÉ®×

[µo°Ý] vba¦Û°ÊÀx¦sºô­¶ÀÉ®×

½Ð°Ý¦p¦óÅý¥H¤Uµ{¦¡½X¡A°õ¦æ¨ìÀɮפU¸üªº®É­Ô¡A¦Û°ÊÀx¦sÀɮצܦP¸ê®Æ§¨¨Ã«O«ù­ìÀɦW.csvÀÉ(¤U¸üÀɮ׬°.csvÀÉ)

Sub ¬d¸ß¨C¤é¼Æ¾Ú¨Ã¤U¸üÀÉ®×()
Dim indexer As Integer
indexer = 6656 + Day(Now()) - 23

Set myIE = CreateObject("InternetExplorer.Application")
With myIE
.Visible = true
.Navigate "http://xxxxxxxxxxxx/xxx.aspx" '¬d¸ß¼Æ¾Úºô§}

Do While .ReadyState <> 4
DoEvents
Loop

.Navigate "javascript:__doPostBack('ct600$phCondition3$cldDate','" & indexer & "')"
Application.Wait Now + 2 / 86400 'µ¥«Ý2¬í
.document.forms(0).all("ct600_btnConfirm").Click 'ÂI¿ï¬d¸ß«ö¶s

.Navigate "http://10.178.1.140:8023/ReportPage/ReportAgentToDay_28_tptv.aspx" '¬d¸ß¼Æ¾Ú·|¦Û°Ê²£¥Í©ó¦¹ºô§}­¶­±

Do Until .ReadyState = 4
DoEvents
Loop

.document.forms(0).all("ctl00_btnDownload").Click 'ÂI¿ï¤U¸ü«ö¶s

'ÂI¿ï¤U¸ü«ö¶s«á¡Aºô­¶·|¼u¥X¤U¸üÀÉ®×µøµ¡¡A¸ß°Ý"¶}±ÒÂÂÀÉ"¡B"Àx¦s"¡B"¨ú®ø"¿ï¶µ
'§Æ±æ¯à¦Û°ÊÀx¦s¦Ü¦P¸ê®Æ§¨¨Ã«O«ù­ìÀɦW.csvÀÉ(¤U¸üÀɮ׬°.csvÀÉ)
'½Ð°Ý¥H¤W³o¬qµ{¦¡½X¸Ó«ç»ò¼g©O¡H


End With
End Sub

*¦v¤k¤@ªTµL»~*

¦^´_ 1# msmplay
¦p¹ÏIE¤W²¾°Ê·Æ¹«¨ìCSV¤U¸üªº¦ì¸m,¥i¬Ý¨ìÀɮתººô§}

  1. Option Explicit
  2. Const FileName = "d:\mycsv.csv" '¦sÀɦì¸m¿ý¡A¥i¦Û¦æ­×§ï
  3. Const URL = "http://www.twse.com.tw/exchangeReport/STOCK_DAY?response=csv&date=20180101&stockNo=2303"
  4. Sub Ex_¦sÀɤ@()
  5.     Application.DisplayAlerts = False
  6.     With Workbooks.Open(URL)
  7.         .SaveAs FileName
  8.         .Close
  9.     End With
  10.     Application.DisplayAlerts = True
  11. End Sub
  12. Sub Ex_¦sÀɤG()
  13.     Dim Xmlhttp As Object
  14.     Set Xmlhttp = CreateObject("WinHttp.WinHttpRequest.5.1")
  15.     With Xmlhttp
  16.         .Open "POST", URL, False
  17.         .Send
  18.     End With
  19.     With CreateObject("ADODB.Stream")
  20.         .Type = 1
  21.         .Open
  22.         .write Xmlhttp.ResponseBody
  23.         If Dir(FileName) <> "" Then Kill FileName '¬Û¦P¦WºÙªºÀɮצs¦b·|¦³¿ù»~
  24.         .SaveToFile FileName
  25.     .Close
  26.     End With
  27. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

use win api

TOP

¦^´_ 2# GBKEE


   G¤j~~~´ú¸Õ¤w¦¨¥\¡A«D±`·PÁ¼ö¤ßÀ°¦£~~~~~~~~
*¦v¤k¤@ªTµL»~*

TOP

        ÀR«ä¦Û¦b : ¤@­Ó¤H¤£©È¿ù¡A´N©È¤£§ï¹L¡A§ï¹L¨Ã¤£Ãø¡C
ªð¦^¦Cªí ¤W¤@¥DÃD