Re: VBA and switching focus between applications
- From: "Valmont" <notrelevant@xxxxxxxxxxxxx>
- Date: Mon, 24 Mar 2008 21:17:52 +0100
Well I've gotten so far: just iterate through open instances. If the URL
matches the URL that the employee uses then I can analyse the document of
that url.
Next thing is to figure out how to iterate through all objects in a html
page...
You helped me great so far. It directs towards the right track.
"JP" <jp2112@xxxxxxxxxxxxx> schreef in bericht
news:095b303f-5745-4716-ad6a-cd1e5341d085@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
You can hook into an existing instance of IE like this:
Dim appIE As Object
On Error Resume Next
Set appIE = GetObject(,"InternetExplorer")
On Error Goto 0
If appIE Is Nothing Then
MsgBox "Cannot find IE"
Exit Sub
End If
HTH,
JP
On Mar 24, 9:01 am, "Valmont" <notrelev...@xxxxxxxxxxxxx> wrote:
I need to add that I cannot open IE from within VBA code. The IE page is
always open. So I can't use vba to open IE and navigatie to an url as IE
is
always open on the same url, but contents may vary.
So how do I analyse the webpage with VBA - like: what control has the
focus
at the moment?
The trick is that I don't want to focus on a single control persé. I
probably need the contents of the entire page.
"Valmont" <notrelev...@xxxxxxxxxxxxx> schreef in
berichtnews:47e7a108$0$2844$6c4159fb@xxxxxxxxxxxxxxxxxxxx
The answer is :
AppActivate "paste.doc - Microsoft Word", True
The next question is: how do I select the entire webpage so all its
contents are copied, not just a randomly - unknown - selected control?
Gosh I feel noob-like :).
"Valmont" <notrelev...@xxxxxxxxxxxxx> schreef in bericht
news:47e79fed$0$2842$6c4159fb@xxxxxxxxxxxxxxxxxxxx
Well, I came up with this:
Private Sub CommandButton1_Click()
AppActivate "Google - Mozilla Firefox"
SendKeys "^a"
SendKeys "^c"
AppActivate "paste.doc - Microsoft Word"
SendKeys "^v"
End Sub
However, "^V" (pasting) doesn't work although the copied content is in
the clipboard. Any suggestions?
"JP" <jp2...@xxxxxxxxxxxxx> schreef in bericht
news:7ec652d0-5c89-40c9-ad54-b3378c4e8d06@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have some sample code for automating Internet Explorer here:
http://codeforexcelandoutlook.com/automateinetexplorer.html
http://tinyurl.com/2twmh9
It depends on what type of website you are accessing, but a lot of
them can be accessed via code. Keep in mind it might be less tedious
to push a button, but the VBA code in many cases will be slower.
HTH,
JP
On Mar 19, 2:47 pm, "Valmont" <notrelev...@xxxxxxxxxxxxx> wrote:
An employee works with a VBA application (form in Word 2003), side
by
side
with a page on Internet Explorer. From that webpage he copies
manually
data to controls in the userform. This costs too much (time).
My solution would be to build additional functions in VBA. It goes
like
this:
1) Press a button on the form.
2) The code behind "button_clicked" event switches focus to the open
Internet Explorer webpage (defined by the windowtitle in he blue
area).
3) I use sendkeys CTRL_A then CTRL_Copy to copy the webpage contents
to
the clipboard.
4) Event switches back to the VBA form (Word 2003 instance).
5) VBA code analyses the data on the clipboard and copies the right
stuff
to the controls.- Hide quoted text -
- Show quoted text -
.
- Follow-Ups:
- Re: VBA and switching focus between applications
- From: Valmont
- Re: VBA and switching focus between applications
- References:
- VBA and switching focus between applications
- From: Paris Hilton
- Re: VBA and switching focus between applications
- From: Valmont
- Re: VBA and switching focus between applications
- From: JP
- Re: VBA and switching focus between applications
- From: Valmont
- Re: VBA and switching focus between applications
- From: Valmont
- Re: VBA and switching focus between applications
- From: Valmont
- Re: VBA and switching focus between applications
- From: JP
- VBA and switching focus between applications
- Prev by Date: Re: Resize application window - more information
- Next by Date: Re: Resize application window - more information
- Previous by thread: Re: VBA and switching focus between applications
- Next by thread: Re: VBA and switching focus between applications
- Index(es):