Opening a secured file in IE using VBA

clide91

New Member
Joined
Apr 22, 2014
Messages
5
I'm writing a VBA script that will open internet explorer, navigate to a certain webpage, apply search filters, submit the search form, and click the "Export to Excel" button for the table of data that gets presented. The code is working perfect up to the point of clicking the button to export to Excel. I think it's a problem with security since it's on my companies Intranet and opens as a read only after selecting to "Open" the file in the pop-up.

Below is my code I am using


Sub Test_Extract()


Dim IE As Object
Dim Log_ID As Object
Dim Status As Object
Dim From_Date As Object
Dim To_Date As Object
Dim Element As Object
Dim btnInput As Object
Dim ElementCol As Object


Application.ScreenUpdating = False



With CreateObject("Shell.Application").Windows
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "WEBSITE"

End With


' loop until the page finishes loading
Do While IE.Busy
Loop

' enter username and password in textboxes
Set Log_ID = IE.document.getElementsByName("txtID")
If Not Log_ID Is Nothing Then
' fill in log id
Log_ID(0).Value = "9999"
End If

Set Status = IE.document.getElementsByName("drpStatus")
If Not Status Is Nothing Then
' fill in status field
Status(0).Value = "Both"
End If

Set From_Date = IE.document.getElementsByName("cal1")
If Not From_Date Is Nothing Then
' fill in start date
From_Date(0).Value = "01/01/2014"
End If

Set To_Date = IE.document.getElementsByName("cal2")
If Not To_Date Is Nothing Then
' fill in end date
To_Date(0).Value = "04/01/2014"
End If

' Submit the search form
With IE
.document.forms(0).submit
End With



' Click the export button

Set ElementCol = IE.document.getElementsByTagName("btnExcel")
For Each btnInput In ElementCol
If btnInput.Value = "btnExcel" Then
btnInput.Click
Exit For
End If
Next btnInput
Application.ScreenUpdating = True


End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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