Save file through Internet Explorer

swarmo

New Member
Joined
Aug 11, 2016
Messages
21
Hi guys,
I am trying my hardest to figure out how I can save a pdf file on a website automatically. I have got to the point where I am prompted to Open/Save/Cancel the file.
I want to be able to save the file automatically into a folder whose path is specified by a cell. Thanks for any help.

Code:
Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" _
            (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long


Global Const SW_MAXIMIZE = 3
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWNORMAL = 1
Sub OpenIE2()
Dim Report As Variant




    Application.ScreenUpdating = False
   
     
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.Navigate "http://e-services.esv.vic.gov.au/"
    
    apiShowWindow IE.hWnd, SW_MAXIMIZE


    While IE.Busy
        DoEvents
    Wend
     ' **********************************************************************
    delay 1
    IE.Document.All("UserID").Value = "Username"
    IE.Document.All("Password").Value = "Password"
    IE.Document.All("btn").Click
    delay 1
    IE.Navigate "https://e-services.esv.vic.gov.au/Cert/PrintCOES?certno=" & ThisWorkbook.Worksheets("Calculator").Range("H27").Value
[COLOR=#ff0000]'****This will prompt Internet Explorer to download the pdf file. It then gives me the option to Open/Save/Cancel. I'm using IE 11
'****I am trying to figure out how to save the file directly into a folder, specified by a cell reference. I need to be logged in order to be able to access the file
'****which is why I think I am limited to using Internet Explorer through excel. [/COLOR]
[COLOR=#ff0000]        [/COLOR]


        '**********************************************************************
    Set IE = Nothing
 End Sub
 Private Sub delay(seconds As Long)
    Dim endTime As Date
    endTime = DateAdd("s", seconds, Now())
    Do While Now() < endTime
        DoEvents
    Loop
End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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