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.
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