473,473 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Automate IE via VB - Change focus of object.

7 New Member
Hi, im using VB to automate IE and its only my 3rd time. The website im trying to automate populates another IE window and I cant figure out how to change the focus of the automation to the new window? Any ideas?
Jan 24 '08 #1
9 7961
debasisdas
8,127 Recognized Expert Expert
can you please pass few more details what exactly you are trying to do .
Jan 25 '08 #2
cbanks
7 New Member
can you please pass few more details what exactly you are trying to do .
im using the code below to advance to a certain webpage. and once i get to that webpage i select an option. When i select that option a new window appears. I need to work with that new window, but be able to go toggle back to the other window when neccessary. When i try my code it never performs the actions i am asking on the new object. My code is right if i could just get it to recognize the new window and work on it.

[PHP
Set ie = CreateObject("InternetExplorer.application")
ie.Visible = True
ie.navigate ("Secure Info")
Set doc = ie.document
Set ctl = doc.getElementById("property(txtFormattedPolicy)")

ctl.Value = ""
ie.document.all.Item("btnRunSearch").Click **New window pops up here.

[/PHP]
Jan 25 '08 #3
WinblowsME
58 New Member
What is the URL to the popup window? Navigate to the URL using the browser object.
Jan 25 '08 #4
cbanks
7 New Member
The url changes constantly. It depends on what option i click. Is there another way besides navigating the original object to the new windows url?
Jan 25 '08 #5
WinblowsME
58 New Member
What if you create a new object that navigates to the popup URL? What exactly are you trying to automate?
Jan 25 '08 #6
cbanks
7 New Member
Im trying to automate my companies internet based system. The new url depends on alot of different information. Policy, username, client name.. etc...
Jan 25 '08 #7
WinblowsME
58 New Member
Check out Ken's last post at the following link.

http://www.vbaexpress.com/forum/printthread.php?t=1058

Expand|Select|Wrap|Line Numbers
  1. ' Tools -> References -> Microsoft Internet Controls
  2.  
  3. Sub Test()
  4.    ' Dim IE As Object
  5.    Dim sws As SHDocVw.ShellWindows
  6.    Dim i As Integer
  7.  
  8.    Set sws = New SHDocVw.ShellWindows
  9.  
  10.    For i = 0 To sws.count - 1
  11.       Debug.Print (sws.item(i).LocationURL)
  12.       ' Find the URL you want and set the IE object
  13.       ' Set IE = sws.Item(i).Document
  14.    Next i
  15. End Sub
Jan 25 '08 #8
WinblowsME
58 New Member
Open up a few IE windows, make sure one of the URL's is set to http://www.google.com and run the code.

Expand|Select|Wrap|Line Numbers
  1. ' Tools -> References -> Microsoft Internet Controls
  2.  
  3. Sub Test()
  4.    Dim IE As Object
  5.    Dim sws As SHDocVw.ShellWindows
  6.    Dim i As Integer
  7.  
  8.    Set sws = New SHDocVw.ShellWindows
  9.  
  10.    For i = 0 To sws.count - 1
  11.       If sws.item(i).LocationURL = "http://www.google.com/" Then
  12.          Set IE = sws.item(i).Document
  13.          Exit For
  14.       End If
  15.    Next i
  16.  
  17.    IE.All("q").Value = "Diablo II"
  18.    IE.All("btnG").Click
  19.  
  20.    Call Wait(IE)
  21. End Sub
  22.  
  23. Private Sub Wait(IE As Object)
  24.    While IE.ReadyState <> "complete"
  25.       DoEvents
  26.    Wend
  27. End Sub
Jan 25 '08 #9
cbanks
7 New Member
thank you. i believe i can make this work. how do i select a hyperlink once im on the page?

javascript:CSWCVC_linkChangePolicy
Feb 6 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use...
3
by: GBW | last post by:
I'm new to VB .NET development - I'm trying to create a text box that as soon 3 characters are entered the focust will then move to the next text box I've tried using MaxLength or...
13
by: Stefan | last post by:
hello, Just a sort of newbie question. How can i change the backcolor of the controls which have the focus (textbox/combobox/datetimepicker) and set it back to white when they lost focus. thanx...
0
by: Agnes | last post by:
I had created a textbox usercontrol , My aim is "once the textbox got focus, its backcolor become lightgray", lost focus will change back to default.Please be kind to help. Private Sub...
4
by: Jon Slaughter | last post by:
I've created some custom controls and forms that allow the feature to temporarily transfer focus to a control that has been entered by the mouse. Everything seems to work fine but the problem I...
1
by: Sankalp | last post by:
Hi, I am using VB 2005. My application has many data bound controls. The connection is stored in the app.config file. I want the application to start with a default connection string and while...
3
by: viral123 | last post by:
Hi all, does any one know how to get the functionality of get focus and lost focus using ASP.Net like VB.Net I want to change the textbox back ground color when it has the focus. I used...
2
by: =?Utf-8?B?QWxleGFuZGVyIFd5a2Vs?= | last post by:
Is it possible to automate a COM object ebmeded in an excel document run the process and return the results in a C# .NET application? Or better yet extract the com object some how and just run it...
10
by: engteng | last post by:
When textbox properties enable = False the font in the textbox become gray color. How do I change the gray color to black color ? Regards, Tee
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.