ie.Navigate save file to folder?
Results 1 to 4 of 4

Thread: ie.Navigate save file to folder?

  1. #1
    Board Regular
    Join Date
    Nov 2016
    Posts
    585
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default ie.Navigate save file to folder?

    Hi,
    I managed to login to site then navigate to specific URL which is a JSON

    After loading the page, a prompt comes up to open/save JSON

    Is there a way I can save this to a specific folder with VBA?

  2. #2
    Board Regular Worf's Avatar
    Join Date
    Oct 2011
    Location
    Rio, Brazil
    Posts
    3,676
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    2 Thread(s)

    Default Re: ie.Navigate save file to folder?

    This example shows how to download a text file without Internet Explorer:

    Code:
    Sub DloadFile()
    Dim ostream, wreq As Object
    Set wreq = CreateObject("Microsoft.XMLHTTP")
    wreq.Open "GET", "https://raw.githubusercontent.com/jdorfman/" & _
    "awesome-json-datasets/master/tests/relaxed.json", False
    wreq.send
    If wreq.Status = 200 Then
        Set ostream = CreateObject("ADODB.Stream")
        ostream.Open
        ostream.Type = 1
        ostream.Write wreq.responseBody
        ostream.SaveToFile "C:\pub\file.json", 2    ' overwrite
        ostream.Close
    End If
    End Sub
    Excel 2013 / Windows 8.1 (home)
    Excel 2013 / windows 7 (work)


  3. #3
    Board Regular
    Join Date
    Nov 2016
    Posts
    585
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Re: ie.Navigate save file to folder?

    @Worf
    Thanks for the reply but it isn't this simple as the site requires secure login.

    I managed to automate this with IE, though stuck at the (Open /Save) notification bar that pops up.

    Tried lots of code from various sites but no luck.

  4. #4
    Board Regular
    Join Date
    Oct 2007
    Posts
    5,807
    Post Thanks / Like
    Mentioned
    8 Post(s)
    Tagged
    2 Thread(s)

    Default Re: ie.Navigate save file to folder?

    Try calling the IE_Download_File_Using_UIAutomation routine at https://www.mrexcel.com/forum/genera...ml#post5221771, as shown in the test example.

    Note that, as written, the code outputs debugging information to the first sheet. Change the following line to False to disable the debugging:
    Code:
    Const DebugMode As Boolean = True

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •