Opening an IE window from another IE window

K

keith.crunk

Hello,

I am trying to write some code in order to download data off the
internet. It involves going to a website, running a query, exporting
the query to a .csv file, and downloading the file. I am experiencing a
problem when trying to export the query.

When doing it manually, after the query is run, you can select an
"Export" option from a drop down menu. Selecting that causes a new IE
window to open and it asks if you would like to export as a .csv or a
..pdf. You make your choice, and you click Submit.

There is a specific web address you can enter to bring up the prompt
that asks you if you want to export as a .csv or .pdf. The only problem
is, if you just have an IE window navigate to that address, it does not
link that site to a query. It just opens the web address as is. So I
want the code to behave just as doing it manually would, meaning, I
want a new IE window to open from the original IE window.

My code:

*****

Sub getOutages()

Dim IE As Object, url As String, url2 As String, url3 As String,
url4 As String, url5 As String
Dim IE2 As Object

Set IE = CreateObject("internetexplorer.application")

'''This is the url of the website.
url = "http://www.... com"
'''This is the url that shows the results of the query.
url2 = "http://www.... com"
'''This is the url that shows the prompt for exporting as .csv or
..pdf.
url3 = "http://www.... com"

Set IE2 = CreateObject("internetexplorer.application")

With IE
.Visible = True
.navigate url (opens the website)
.navigate url2 (runs the query)
IE2.visible = True
.navigate url3
''' Somehow I would like url to be navigated from IE but
for it to be opened in IE2.

End With
End Sub

*****

Any help on this would be greatly appreciated! Thanks!!!!

- Keith
 
P

Paul Lautman

Hello,

I am trying to write some code in order to download data off the
internet. It involves going to a website, running a query, exporting
the query to a .csv file, and downloading the file. I am experiencing
a problem when trying to export the query.

When doing it manually, after the query is run, you can select an
"Export" option from a drop down menu. Selecting that causes a new IE
window to open and it asks if you would like to export as a .csv or a
.pdf. You make your choice, and you click Submit.

There is a specific web address you can enter to bring up the prompt
that asks you if you want to export as a .csv or .pdf. The only
problem is, if you just have an IE window navigate to that address,
it does not link that site to a query. It just opens the web address
as is. So I want the code to behave just as doing it manually would,
meaning, I want a new IE window to open from the original IE window.

My code:

*****

Sub getOutages()

Dim IE As Object, url As String, url2 As String, url3 As String,
url4 As String, url5 As String
Dim IE2 As Object

Set IE = CreateObject("internetexplorer.application")

'''This is the url of the website.
url = "http://www.... com"
'''This is the url that shows the results of the query.
url2 = "http://www.... com"
'''This is the url that shows the prompt for exporting as .csv or
.pdf.
url3 = "http://www.... com"

Set IE2 = CreateObject("internetexplorer.application")

With IE
.Visible = True
.navigate url (opens the website)
.navigate url2 (runs the query)
IE2.visible = True
.navigate url3
''' Somehow I would like url to be navigated from IE but
for it to be opened in IE2.

End With
End Sub

*****

Any help on this would be greatly appreciated! Thanks!!!!

- Keith

Why worry about the csv. Why not just create an Excel web query and get the
data from url2?
 
P

Paul Lautman

Hello,

I am trying to write some code in order to download data off the
internet. It involves going to a website, running a query, exporting
the query to a .csv file, and downloading the file. I am experiencing
a problem when trying to export the query.

When doing it manually, after the query is run, you can select an
"Export" option from a drop down menu. Selecting that causes a new IE
window to open and it asks if you would like to export as a .csv or a
.pdf. You make your choice, and you click Submit.

There is a specific web address you can enter to bring up the prompt
that asks you if you want to export as a .csv or .pdf. The only
problem is, if you just have an IE window navigate to that address,
it does not link that site to a query. It just opens the web address
as is. So I want the code to behave just as doing it manually would,
meaning, I want a new IE window to open from the original IE window.

My code:

*****

Sub getOutages()

Dim IE As Object, url As String, url2 As String, url3 As String,
url4 As String, url5 As String
Dim IE2 As Object

Set IE = CreateObject("internetexplorer.application")

'''This is the url of the website.
url = "http://www.... com"
'''This is the url that shows the results of the query.
url2 = "http://www.... com"
'''This is the url that shows the prompt for exporting as .csv or
.pdf.
url3 = "http://www.... com"

Set IE2 = CreateObject("internetexplorer.application")

With IE
.Visible = True
.navigate url (opens the website)
.navigate url2 (runs the query)
IE2.visible = True
.navigate url3
''' Somehow I would like url to be navigated from IE but
for it to be opened in IE2.

End With
End Sub

*****

Any help on this would be greatly appreciated! Thanks!!!!

- Keith

And why are you bothering to go to url1 in the first place?
 
K

keith.crunk

I haven't ever created an Excel web query, so I'm not really sure what
to do for that. I'm not overly concerned with doing it the most
efficient way. I just want it to work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top