AUTOMATE SAVE BUTTON CLICK

LuisOrtin

New Member
Joined
Mar 27, 2020
Messages
27
Office Version
  1. 2019
Platform
  1. Windows
But once I need help from friends, in this procedure I need to automate the click on the "save" button and want to replace "yes" as follows:

VBA Code:
Sub ScrapeOddsUsingIE()
    Dim IE As New SHDocVw.InternetExplorer
    Dim objPic      As Picture
    
'ACCESS THE WEBSITE AND WAIT TO LOAD
    IE.navigate "https://gru.inpi.gov.br/pePI/"
    IE.Visible = True
    Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy
    Loop

'COPY COMPLETE HTML TO FOLDER
   IE.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DODEFAULT, "C:\Temp\inpi.html"
  
   'HERE I NEED TO CLICK MANUALLY TO SAVE AND REPLACE YES (I NEED TO AUTOMATE THIS PAST)
  
    Set objPic = ActiveSheet.Pictures.Insert("C:\Temp\INPI_arquivos\faleconosco.png")
End Sub
 

Attachments

  • Print tela.png
    Print tela.png
    136.1 KB · Views: 3

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

lrobbo314

Well-known Member
Joined
Jul 14, 2008
Messages
2,954
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
I don't know if the keyboard shortcuts are the same when it's in Portuguese, but you can use SendKeys to simulate a keyboard key. We can press Y for "yes", SendKeys ("Y"), or maybe it's S for "sim" SendKeys ("S").
 

LuisOrtin

New Member
Joined
Mar 27, 2020
Messages
27
Office Version
  1. 2019
Platform
  1. Windows
I tried to use SendKeys in several ways.
But I don't know why it doesn't simulate the key.
Could it be some configuration of my IE?
 

lrobbo314

Well-known Member
Joined
Jul 14, 2008
Messages
2,954
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
I see. The sendkeys is being held up by the dialog box. Tente isso.

VBA Code:
Sub DownloadFile()
Dim url As String:          url = "https://gru.inpi.gov.br/pePI/jsp/imagens/faleconosco.png"
Dim WinHttpReq As Object:   Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")

WinHttpReq.Open "GET", url, False
WinHttpReq.send

If WinHttpReq.Status = 200 Then
    Set oStream = CreateObject("ADODB.Stream")
    oStream.Open
    oStream.Type = 1
    oStream.Write WinHttpReq.responseBody
    oStream.SaveToFile "C:\Temp\inpi.html", 2 ' 1-no overwrite, 2-overwrite
    oStream.Close
End If

End Sub
 

LuisOrtin

New Member
Joined
Mar 27, 2020
Messages
27
Office Version
  1. 2019
Platform
  1. Windows

ADVERTISEMENT

My God !
It worked perfectly, thank you very much!
 

Watch MrExcel Video

Forum statistics

Threads
1,119,284
Messages
5,577,200
Members
412,776
Latest member
nadroy87
Top