Save web page without prompting

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Save web page without prompting

Post by YasserKhalil »

Hello everyone
I have found this code that saves a web page offline but it shows a dialog of save .. How can to save automatically to a desired path with prompting

Code: Select all

Sub Example()
    Dim URL As String, IE As New InternetExplorer
    
    IE.Visible = True
    MsgBox IIf(SavePage(URL, ThisWorkbook.Path & "\", IE), "Page Saved", "Page Not Saved")
     
End Sub

Private Function SavePage(URL As String, SaveToPath As String, IE As InternetExplorer) As Boolean
    On Error GoTo Err_SavePage
    
    IE.navigate "https://locations.wendys.com/al"
    'you should provide a timeout
    Do
        DoEvents
    Loop While Not IE.readyState = 4
    
    IE.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DODEFAULT
    SavePage = True
    
    Exit Function
Err_SavePage:
End Function

User avatar
HansV
Administrator
Posts: 78481
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Save web page without prompting

Post by HansV »

Just for your information: I don't have the slightest idea how to do this, so don't wait for an answer from me.
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Re: Save web page without prompting

Post by YasserKhalil »

Thanks a lot Mr. Hans
It seems that it has no solution to suppress the save button .. after some searches