Access newly created tab

by perryworld at 2013-02-25 03:03:44

Hi All,

As part of our process we open a new tab which contains a printer friendly version of our report but then when we try to print the page it still has focus on the originating page and not the newly created page. How would we get a handle on the new page so we can print it and then close it.

Any help appreciated

by poshoholic at 2013-02-25 11:03:57
Hi Richard,

Could you provide some more detail? The question seems to be missing context as is (open a new tab in what application? what are you automating?).

by perryworld at 2013-02-25 12:35:36
Sorry Kirk,

We are using Internet explorer and when we open our web site we navigate to one of our reports, the next step is to select the print button and click it.
This opens the printer friendly version of the report. I’ve read somewhere in google that you can use navigate2 but we open the page by clicking the print button.
Once the printer friendly page is open in the new tab we need to access that tab so we can print it and then close it. This is a process that loops through several reports so we need to automate it.

Hope that makes it a bit clearer

by poshoholic at 2013-02-25 19:36:52
Hi Richard,

That helps. I haven’t figured out all of the pieces, but I did get part way there. You were looking for the handle for the new page. Here is how you can get that:
# Create an IE instance
$ie = New-Object -ComObject InternetExplorer.Application
# Open a tab
# Show IE
$ie.Visible = $true
# Now open another tab (this is in the background)
# To get the information for the second tab, do this:
$sa = New-Object -ComObject Shell.Application
$secondTab = $sa.Windows() | Where-Object {$_.LocationUrl -match ''}
# Here is the handle for that tab
# And all properties

I’m at a loss right now on where to go from here, and I don’t have time to dig in deeper. Does this get you closer to what you need?
by perryworld at 2013-02-26 05:18:03
Thanks Kirk

I will give it a try and let you know.

Thanks for your help,