Jump to content
Sign in to follow this  

IE10 File Download/Save from Acess VBA macro

Recommended Posts

Hi all,

I have been working on an Access 2010 DB importing files and massaging data to produce a final useful table.

As a start to the process, I need to download 5 different files from 3 password secured web sites. I am using TWebst to navigate IE 10 (as I am also running other data collection routines from other sites than the three mentioned above).

I have been struggling with the File Save As on the Download piece. Each file is created and sent to the borwser by a Server side Javascript program executed once the button is pressed. I do this with TWebst.

So I get to the point where IE presents the small window at the bottom of the browser with the Open / Save / Cancel buttons.

Adrian from Twebst suggested today I check out AutoIt as a workaround to the fact Twebst does not have the functionality to control the IE download window.

I have downloaded AutoIt and done some research, but I am still at a loss to understand how to integrate the two (I am a basic VBA programmer, so please be kind!).

I would like to know how to incorporate the AutoIt code in the VBA (rather than external exe/script). If it has to be an external exe/script then I need to feed to it the download path as a parameter to repeat its use for the other files.

I have registered the ActiveX "AutoItX3 1.0 Type Library" control in Tools/References within Acess VBA Editor.

Any suggestions / examples I can follow would be REALLY appreciated. Thanks in advance for any help you provide!

Here's the VBA routine for one of the download portals:

Private Sub DownloadDD()

    Set core = New TwebstLib.core
    Set browser = core.StartBrowserVba(urlDD)
'* DD Log In
    Call browser.FindElementVba("input text", "id=panel-login-name").InputText(uidDD)
    Call browser.FindElementVba("input text", "id=panel-login-account").InputText(namDD)
    Call browser.FindElementVba("input password", "id=panel-login-password").InputText(pwdDD)
    Call browser.FindElementVba("a", "id=login-button").Click

    Set objCollection = browser.FindAllElementsVba("div", "id=panelLoggedIn")
    If objCollection.length > 0 Then
        Call browser.Navigate(catDD)

' Here's where I want to "Save file as" default file name and ConstSavePath (the path is a constant elsewhere in my code)'

    End If

'* DD Log Out
    'Call browser.Close

End Sub
Edited by MarcusL

Share this post

Link to post
Share on other sites

Guys, a hint or some direction would be really appreciated. I am just struggling to bring the two tools together. Thanks for any advice.

Share this post

Link to post
Share on other sites

You can do this all in AutoIt if you want, just change your VBA routine to run your script instead. Check out the IE.au3 functions, the script will look pretty similar to what you already have in VBA as far as layout goes. Since it is javascript, you will likely need to automate clicks on the screen, so that you can click the dialog and save your file.

As far as taking command lines, that is just this variable in your script:

$CmdLine[1] ; first arg
$CmdLine[2] ; second arg

I might have a better answer for you in a few hours after I get home from work, but I have a busy weekend ahead so I may run out of time. Hopefully this helps to point you in the right direction. 

Share this post

Link to post
Share on other sites



Thanks all for the overwhelming help and support

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer. Or if not - tough! ;)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...