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

[µo°Ý] ·Q½Ð±Ð¨Ï¥ÎFindWindow«ö¤U¹ï¸Ü®Øªº"Àx¦s"

[µo°Ý] ·Q½Ð±Ð¨Ï¥ÎFindWindow«ö¤U¹ï¸Ü®Øªº"Àx¦s"

§Ú·Q§ì¨ú¦bgoogle trend ªºCSV¡A¦ý·í§ÚÂI¿ï¤U¸üCSVªº«ö¶s®É¡A·|¥ý¥X²{¹ï¸Ü®Ø¡A§Ú·QÂI¿ï¹ï¸Ü®Øªº"Àx¦s"¡A¦ýºÉ¶q¤£­n¥Îsendkeyªº¤è¦¡
¦p¹Ï

§Ú¦³google¨ìfindwindow¨Ó¸Ñ¨M¡A¦ýÁÙ¬O¤£¤Óª¾¹D¦p¦óÀ³¥Î
·Q½Ð°Ýª©¤W¦U¦ì°ª¤â¡AÁÂÁÂ
¬ÛÃöºô§}
google trend:
https://trends.google.com.tw/trends/explore?q=%E5%8F%B0%E7%A9%8D%E9%9B%BB

§Ú§ä¨ìªº¬ÛÃöµª®×¡A¦ý¬Ý±o¤£¬O«ÜÀ´
https://www.mrexcel.com/forum/excel-questions/567033-automate-file-download-dialog-box-without-sendkeys.html
¨Ï¥Îfindwindow®É­n¥ý¥[¤J

Private Declare Function FindWindowEx Lib "user32" Alias _
"FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

©M

Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

³Ì«á¬O§Úªºcode
  1. Sub googleTrend()

  2. Dim IE As Object
  3. Dim myhtml As Object

  4. [A5].CurrentRegion.Clear

  5. Set IE = CreateObject("InternetExplorer.Application")
  6. Set myhtml = CreateObject("htmlfile")

  7. With IE
  8.     .Visible = False
  9.     .Navigate "https://trends.google.com.tw/trends/explore?q=%E5%8F%B0%E7%A9%8D%E9%9B%BB"
  10.     Do While .Busy Or .readyState <> 4: DoEvents: Loop
  11.    
  12.     Dim doc
  13.     Set doc = .document
  14.    
  15.     Dim myButton
  16.     Dim myButtons
  17.    
  18.     Call delay
  19.     Set myButtons = doc.getElementsByTagName("button")
  20.     For Each myButton In myButtons
  21.         If myButton.getAttribute("title") Like "*CSV*" Then
  22.             myButton.Click
  23.             Call delay
  24.             
  25.             Application.SendKeys ("%{s}")
  26.             Exit For
  27.         End If
  28.         'Debug.Print myButton.getAttribute("title")
  29.     Next
  30.    
  31.     Dim theCSV
  32.     Dim WB
  33.     Dim theData
  34.     theCSV = "C:\Users\User\Downloads" & "\" & "multiTimeline.csv"
  35.     If Dir(theCSV) <> "" Then Kill theCSV
  36.     On Error GoTo errHandler
  37. continue:
  38.     Set WB = Workbooks.Open(theCSV)
  39.     With WB.ActiveSheet
  40.         Set theData = .[A1].CurrentRegion
  41.         ThisWorkbook.Sheets("¤u§@ªí1").[A5].Resize(theData.Rows.Count, theData.Columns.Count) = theData.Value
  42.     End With
  43.     WB.Close
  44.     Set WB = Nothing
  45.     Kill theCSV
  46.    
  47.     .Quit
  48.     Set IE = Nothing
  49. End With

  50. Exit Sub

  51. errHandler:
  52. On Error GoTo 0
  53. Call delay
  54. GoTo continue

  55. End Sub

  56. Sub delay()
  57. Application.Wait Now() + TimeValue("00:00:03")
  58. End Sub
½Æ»s¥N½X
·PÁÂ
Excel VBAºô­¶¸ê®Æ¦¬¶°±Ð¾Ç:
http://forum.twbts.com/thread-20848-1-1.html

        ÀR«ä¦Û¦b : ¦a¤WºØ¤Fµæ¡A´N¤£©öªø¯ó¡F¤ß¤¤¦³µ½¡A´N¤£©ö¥Í´c¡C
ªð¦^¦Cªí ¤W¤@¥DÃD