• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to save File from internet explorer.

Nitesh Khot

Member
Hi Any idea to save file from Internet explorer...

How to activate and save file from internet explorer ....using VBA code..

Please note :- Every time file name changes.....so file name is different as shown in picture...


I have used appactivate or Windows activate command and sendkeys but nothing working ...
zqRSt.jpg
 
Hi...

The URL is intranet ....work on internal LAN only...

IE Version : 9.0.8112.16421

Everything is working fine..but unable to click save button...or send key


Code:
 Sub test()
     Dim Report As Variant
' open IE, navigate to the desired page and loop until fully loaded
    Set ie = CreateObject("InternetExplorer.Application")
    my_url = "http://10.14.15.40:6005/Login.aspx"

    With ie
        .Visible = True
        .navigate my_url
        .Top = 50
        .Left = 530
        .Height = 400
        .Width = 400

Application.Wait Now + TimeSerial(0, 0, 2)
    Do Until Not ie.Busy And ie.readyState = 4
        DoEvents
    Loop
Application.Wait Now + TimeSerial(0, 0, 2)
    End With

' Input the userid and password
    ie.document.getElementById("ux_txtLoginID").Value = "C101"
    Application.Wait Now + TimeSerial(0, 0, 2)
   
    ie.document.getElementById("ux_txtPassword").Value = "c101"
Application.Wait Now + TimeSerial(0, 0, 2)

' Click the "Search" button
    ie.document.getElementById("ux_imgLogin").Click
Application.Wait Now + TimeSerial(0, 0, 2)
    Do Until Not ie.Busy And ie.readyState = 4
        DoEvents
    Loop
   
   ie.document.getElementById("ctl00_ux_txtPage").Value = "31"
    Application.Wait Now + TimeSerial(0, 0, 2)
   
    ie.document.getElementById("ctl00_ux_btnSearch").Click
   
    Application.Wait Now + TimeSerial(0, 0, 2)
   
    ie.document.getElementById("ctl00_ux_FileContent_btnExport").Click
   
   
    Do Until Not ie.Busy And ie.readyState = 4
        DoEvents
        Loop

Below code not wroking
     'obj.AppActivate "MIS >> Admin:: Export to Excel"
AppActivate("InternetExplorer.Application")
'windows("MIS >> Admin:: Export to Excel").activate
'Report = Application.GetSaveAsFilename("*", "Excel Files (*.xls), *.xls")
 Application.SendKeys ("%s")

End Sub
 
You're lucky with your IE version !
So it's a bad use of SendKeys or the coding of webpage can't allow it …

First, try manually. Test the Tab key if after some hits,
active cursor goes from main webpage to this sub window.
If it works, the way by code is to focus on an element of the end
of main webpage and simulate some Tab keys and a final Enter key …

Other way more reliable is like Chihiro link.

But efficient way is to not use IE but to reproduce the request called
by any webbrowser using its inner inspector tool !
See for request ActiveX MSXML2.XMLHttp & WinHttp.WinHttpRequest.5.1 …
 
Back
Top