VBA open file without showing IE window, or without clicking

Llupo01

Active Member
Joined
Aug 17, 2015
Messages
296
Hello,

can somebody pls help? I am using code below. What is desired action is to log in to website, then go to link, which is direct download link to file on this website (link to query, whre auto output is this xlsx file). This is working fine, but I would like to modify code in way, that window of explorer wont be visible (ieapp.visible = false does not do the job)...and I would like to open file without necessary action of clicking on dialog box in IE explorer, where I can chose if to save,open or cancel download.

So best solution would be to not display IE windows, automatically open the file...

or if not possible with hidden window, so to display IE window, but still automatically open file when download link triggered by code. (no need to chose manually by mouse clicking, as action will always be open, never save)

any suggestion and help is appreciated in advance. Thank you.

Code:
Sub GetTable()

Dim ieApp As InternetExplorer
Dim ieDoc As Object
Dim ieTable As Object
Dim clip As DataObject
Dim txtName As OLEObject
Dim txtPass As OLEObject
Dim UserName As String
Dim password As String

Set txtName = ActiveSheet.OLEObjects("txtUserName")
Set txtPass = ActiveSheet.OLEObjects("TxtPassword")
UserName = txtName.Object.Value
password = txtPass.Object.Value

If UserName = "" Then
    MsgBox "Pls specify user name", vbExclamation, "Error"
    Exit Sub
ElseIf password = "" Then
    MsgBox "Pls specify your password.", vbExclamation, "Error"
    Exit Sub
End If

Set ieApp = New InternetExplorer
ieApp.Visible = True
ieApp.navigate "***https:// some hyperlink directly to download file query***"
ieApp.Toolbar = 0
ieApp.StatusBar = 0
ieApp.Width = 1200
ieApp.Height = 900
ieApp.Left = 300
ieApp.Top = 0

Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.readyState = READYSTATE_COMPLETE: DoEvents: Loop

Set ieDoc = ieApp.document

With ieDoc.forms(0)
.login.Value = UserName
.password.Value = password
.submit
End With

Set ieApp = Nothing
txtName.Object.Value = ""
txtPass.Object.Value = ""

End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,213,538
Messages
6,114,218
Members
448,554
Latest member
Gleisner2

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