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

[µo°Ý] vba ¶}±Ò ie ¥t¦s·sÀÉ°ÝÃD

[µo°Ý] vba ¶}±Ò ie ¥t¦s·sÀÉ°ÝÃD

¥H¤U¬O¤p§Ì¦bºô¸ô¤W¬Ýªº¤è¦¡·Ó§ïªº¡C
»Ý­nªº°Ê§@¡A¶}±Òie > ¦C¦Lpdf > ¦Û°Ê±a¤J©Ò»ÝÀɦW > ¦sÀÉ
¥Ø«eªº°Ê§@¡A¶}±Òie > ¦C¦Lpdf ....±¾¤F

¦³°ª¤â¥iÀ°¦£¹À¡H
¹ï¤F¡A¦³¬Ý¨ì¤@½g¤£¿ù¡A7¼Ó GBKEE ¤j³o½g¡A¬°¥t¦sºô­¶¡A¦ý~~¦³¨Ç§Ú­nªººô­¶³£¶]¤£¤F@@
http://forum.twbts.com/viewthread.php?tid=12273
³o¤è¦¡À³¸Ó¥i¤]¥t¦s¦¨pdf§a¡H

ps: ie ¥i§ï¥Î chrome ¨Ó¦C¦Lpdf¹À¡H
pps:¤p§Ì¤£¬O¾Çµ{¦¡ªº¡A©Ò¥H«Ü¦h³£¬Ý¤£À´¡A¥u¬O¤@­Ó¤@­Ó¸Õ
  1. Sub ¤u§@ªí1()

  2.     Sheets("¤u§@ªí1").Select
  3.    
  4. Dim xlsName, xlsNameNo, MyName, NewName, SavePath, DDate, URL As String

  5.     xlsName = ActiveWorkbook.Name                 ''ÀɦW
  6.     xlsNameNo = Mid(s, 1, 4)                      ''ÀɦW«e4¦r¤¸
  7.     MyName = Application.ActiveWorkbook.FullName  ''¸ô®|ÀɦW
  8.     NewName = Left(MyName, Len(MyName) - 5)       ''¥h°£°ÆÀɦW
  9.     SavePath = ActiveWorkbook.Path                ''¸ô®|
  10.     DDate = Format(Date, " _ yyyy-mm-dd")         ''·í¤é¤é´Á
  11.     URL = "http://goodinfo.tw/StockInfo/EquityDistributionClassHis.asp?STOCK_ID=2330"         ''ºô§}
  12.     Cells.Clear

  13.     Application.DisplayStatusBar = True
  14.     Application.ScreenUpdating = False
  15.     Set ie = CreateObject("internetexplorer.application") '¨Ï¥Î¦¹¤è¦¡¥i¥H§K°£ "³]©w¤Þ¥Î¶µ¥Ø"
  16.     With ie
  17.         .Visible = True  'True¬°¶}±Òie, False¬°¤£¶}±Òie
  18.         .Navigate URL

  19.     Do While .Readystate <> 4  'µ¥«Ýºô­¶¶}±Ò
  20.         DoEvents
  21.     Loop

  22.     Application.StatusBar = "¸ê®Æ½Æ»s¤¤½Ðµy­Ô...."
  23.         .ExecWB 6, 2    ''¦C¦L¦¨pdf
  24.         ????????????    ''³o¤@¦ê­n±µ¤°»ò¤~¥i¥H¦Û°Êkey¤JÀɦW©O¡H  ¤ñ¤è»¡¡GfileName =  xlsName &  DDate       ¦bºô¸ô¤W§ä¤F«Ü¦h¦r¦ê¡AÁÙ¬O¤£·|¥Î~

  25.     End With
  26. Application.StatusBar = False
  27.    
  28.     ''ie.Quit  
  29.    
  30. End Sub
½Æ»s¥N½X

¦^´_ 1# koshi0413

ªþ¤W¬ÛÃö¸ê®Æ¡A½Ð¦U¦ì°ª¤â¶}¥Ü¤@¤U......

    2330 ¥x ¿n ¹q.rar (45.34 KB)

TOP

¤µ¤Ñ¦³¦b¸Õ¤F¤@­Ó¤è¦¡  SendKeys
¥i¥H¦sÀɮפU¨Ó¡A¦ýkey¤Jªº¦W¦r¡A±`±`¶]¤£§¹¥þ¡]¦]¬°­n¶]¤­­Óºô­¶¡A¤@­Ó¤@­Ó¶]¡A¶]¤­¦¸¡A¦pªG¤ÏÂФ@ª½«ö¡A¨C¦¸¦sªº¦W¦r­n¬Ý¹B®ð¤~·|¥¿½T¤]¡^
  1. Sub ¤U¸üpdf()
  2. Sheets("¤U¸ü¥Î").Select
  3.    
  4. Dim xlsName, xlsNameNo, MyName, NewName, SavePath, DDate, URL As String

  5.     xlsName = ActiveWorkbook.Name                 ''ÀɦW
  6.     xlsNameNo = Mid(xlsName, 1, 4)                ''ÀɦW«e4¦r¤¸
  7.     SavePath = ActiveWorkbook.Path                ''¸ô®|
  8.     MyName = Application.ActiveWorkbook.FullName  ''¸ô®|ÀɦW
  9.     NewName = Left(MyName, Len(MyName) - 5)       ''¥h°£°ÆÀɦW
  10.     DDate = Format(Date, "yyyy-mm-dd _ ")         ''·í¤é¤é´Á

  11.    
  12.     Cells.Clear
  13.     Application.DisplayStatusBar = True
  14.     Application.ScreenUpdating = False

  15.     ''¸³ºÊ«ùªÑ²{ªp1
  16.     Set ie = CreateObject("internetexplorer.application") '¨Ï¥Î¦¹¤è¦¡¥i¥H§K°£ "³]©w¤Þ¥Î¶µ¥Ø"
  17.     URL = "http://www.fortunengine.com.tw/stock/company/holding.cfm?scode=" & xlsNameNo    ''ºô§}
  18.     With ie
  19.         .Visible = False 'True¬°¶}±Òie, False¬°¤£¶}±Òie
  20.         .Navigate URL

  21.     Do While .Busy: DoEvents: Loop
  22.     Do While .Busy: DoEvents: Loop
  23.     Do While .Readystate <> 4: DoEvents: Loop
  24.         .ExecWB 6, 2
  25.         
  26.    
  27.     Application.Wait Now + TimeValue("00:00:04")
  28.     Application.SendKeys (DDate & xlsNameNo & "_1")
  29.     ''Application.Wait Now + TimeValue("00:00:01")
  30.     Application.SendKeys "{TAB}", True
  31.     ''Application.Wait Now + TimeValue("00:00:01")
  32.     Application.SendKeys "{TAB}", True
  33.     ''Application.Wait Now + TimeValue("00:00:01")
  34.     Application.SendKeys "{TAB}", True
  35.     ''Application.Wait Now + TimeValue("00:00:01")
  36.     Application.SendKeys "{ENTER}", True
  37.     ''Application.Wait Now + TimeValue("00:00:01")
  38.     Application.SendKeys "{TAB}", True
  39.     Application.SendKeys "{ENTER}", True
  40.    
  41.     End With
  42.    
  43.     Application.StatusBar = False
  44.     ie.Quit
  45. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : §g¤l¦p¤ô¡AÀH¤è´N¶ê¡AµL³B¤£¦Û¦b¡C
ªð¦^¦Cªí ¤W¤@¥DÃD