PDA

View Full Version : Select IE and a Specific Tab In IE9



nhmabv
11-17-2012, 08:55 PM
From a word form I need to select and activate a specific tab in IE9 when IE does not have the focus. If the tab within IE is the current tab opened, then the code works, else I get "Unable to activate".
In the tasks properties "Task1.name" is known but "Task1.activate" produces an error if a different tab has the focus.
It works if there is only that one tab open.

This code works if there is only one tab open:
For Each Task1 In Tasks
If Task1.name = "My Tab Name" Then
Task1.Activate
Exit For
End If
Next Task1
Thanks

fumei
11-17-2012, 09:00 PM
Tasks only activates an application, in this case IE. It has no effect on anything happening IN that application. It may be possible to get a different Tab than the active one in IE, but I suspect it would require using an object instance of IE. In other words creating an instance of IE (via CreateObject) and using methods and properties of that instance.

I do not think you can do what you ask using just Word.

nhmabv
11-18-2012, 08:02 PM
How can I just activate IE. If there are more than one tab open, application.activate "Internet Explorer" fails.
If I can get it activated, I can sendkeys to select the tab I want.
Thanks

fumei
11-18-2012, 10:30 PM
But you state:

"This code works if there is only one tab open:
For Each Task1 In Tasks
If Task1.name = "My Tab Name" Then
Task1.Activate
Exit For
End If
Next Task1"

What exactly is working? Have you tried using an IE object?

nhmabv
11-19-2012, 03:51 PM
Yes the code works but only if there is only one tab opened. If there is two or more tabs opened the code produces an error, however, if the first tab is the "Active" tab, that is, if for instance, you did an alt/tab to IE that tab would be visible, the code works.
I know that a IE object can be created, I just dont know what to do with it.
If you could suggest any way to get IE to the focus, I know that sending a control 1 will select the first tab, which will be the right tab 99.9% percent of the time.
Thanks