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: 6

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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").
 
Upvote 0
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?
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,412
Messages
6,119,365
Members
448,888
Latest member
Arle8907

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top