0

I'm trying to download a file through Internet Explorer using VBA (after secure login) Its a JSON file, and when navigating to it i get the pop up bar "Do you want to open or save the file"

I've tried many solutions in posts but none seem to work, appreciate any help with this.

I've tried various solutions from stackoverflow, reddit and excel forums

Here is my current VBA to login to the site with IE:

Sub login()
    Const Url$ = "https:/xxx.com/2020-01-01"

    Dim UserName As String, Password As String, LoginData As Worksheet
    Set LoginData = ThisWorkbook.Worksheets("Sheet1")
    UserName = LoginData.Range("A1")
    Password = LoginData.Range("A2").Value

    Dim ie As Object
    Set ie = CreateObject("InternetExplorer.Application")

    With ie
        .navigate Url
        ieBusy ie
        .Visible = True

        Dim oLogin As Object, oPassword As Object
        Set oLogin = .document.getElementsByName("username")(1)
        Set oPassword = .document.getElementsByName("password")(0)

        oLogin.Value = UserName
        oPassword.Value = Password
        .document.forms(0).submit    
    End With
End Sub

Sub ieBusy(ie As Object)
    Do While ie.Busy Or ie.readyState < 4
        DoEvents
    Loop
End Sub

enter image description here

PeterT
  • 8,232
  • 1
  • 17
  • 38
azza452
  • 25
  • 5
  • Welcome to [so]! Be sure to check out the [tour] (you'll earn your first badge!) as well as "[ask]". This question has been asked/answered several times before. I'd suggest you start with a google search such as [this one](https://www.google.com/search?q=ie+vba+save+open+file+dialog) and if you still can't get it figured out, edit your question to provide a [mcve[ showing what you've tried. – ashleedawg May 19 '19 at 02:53
  • 1
    Have you looked at [this answer](https://stackoverflow.com/a/10400983/4717755)? – PeterT May 19 '19 at 02:55
  • Yes I couldn't get anything from there working – azza452 May 20 '19 at 11:30

0 Answers0