|
-
Aug 9th, 2012, 10:50 AM
#1
Thread Starter
Don't Panic!
[RESOLVED] Access OO > Internet Explorer
Hi,
I can open an instance of internet explorer :
Code:
set objIE = createobject("InternetExplorer.Application")
But how do I get a reference to an already open IE ?
I tried GetObject but it complains :
Set objIE = GetObject(,"InternetExplorer.Application")
ActiveX Component can't create object
or
Set objIE = GetObject("InternetExplorer.Application")
Automation Error, invalid syntax
I'm sure I've done this in the past and its connected to an open IE (not forced user to re-open and browse...)
Any one have any ideas or pointers to websites to read up on this?
(I have a form on a web page and I want to get to the HTML to Parse and store into my mdb)
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Aug 10th, 2012, 04:46 AM
#2
Re: Access OO > Internet Explorer
you can use a shell object to work with an open instance of internet explorer
Code:
set sh = createobject("shell.application")
for each w in sh.windows
' use some criteria here to determine if it is the window you are looking for
' explorer windows always are listed before IE windows
next
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 10th, 2012, 06:08 AM
#3
Thread Starter
Don't Panic!
Re: Access OO > Internet Explorer
Hi,
Thanks. Does that get me the application or just the window?
Sorry for sounding thick, but the intellisense isn't much use in this case...
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Aug 10th, 2012, 07:18 AM
#4
Re: Access OO > Internet Explorer
you can work with the document of the window, and the application of the document
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 10th, 2012, 07:58 AM
#5
Thread Starter
Don't Panic!
Re: Access OO > Internet Explorer
Riiii ght 
Let me have a look into that and I'll get back to you when (if?) I get stuck...
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Aug 10th, 2012, 09:12 AM
#6
Thread Starter
Don't Panic!
Re: Access OO > Internet Explorer
Didn't take me too long to get stuck lol
Tried checking out some information from This MS page which hinted at things I wanted (eg to get to the html of the page showing).
For ease of use I am opening an instance of IE and navigating to the page to log in... and holding the reference to IE so I can 'see' that at least.
From there though, there doesn't appear to be any logical or useful intellisense pop ups. Including defining variables as specific objects to get the intellisense.
objie.container --- this has nothing in it/errors
objie.document --- errors
This is usually followed by Access 2010 crashing out... lovely.
Am I missing some useful references?
Edit:
Code:
?objie.Document
[object]
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Aug 10th, 2012, 10:33 AM
#7
Thread Starter
Don't Panic!
Re: Access OO > Internet Explorer
Last post....
When you use the shell you don't seem to get any of the internetexplorer objects/methods.
So I am going to have to force the user to open an IE from my MDb first then hold the reference to it.
This then does what I need.
Thanks for your patience and pointers.
:thumbs:
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Aug 11th, 2012, 02:34 AM
#8
Re: Access OO > Internet Explorer
Am I missing some useful references?
no references required, but if you reference html, you can use the intellisense, if you declare your variables correctly
When you use the shell you don't seem to get any of the internetexplorer objects/methods.
just needs a little more patience to work out where the objects are
this works correctly, without error, i opened the webpage you linked to above in ie
Code:
Dim doc As HTMLDocument ' reference to html required
Set sh = CreateObject("shell.application")
Set w = sh.Windows(sh.Windows.Count - 1) ' as i only have 1 instance of ie open, it has to be the last window
'Debug.Print w.document.documentelement.innerhtml
Set doc = w.document
intellisense will work for doc as it is declared and referenced
use the locals window to find what elements can be used
shows correct result
So I am going to have to force the user to open an IE from my MDb first then hold the reference to it.
you can do everything from the shell window
you can also reference shell automation, but beyond getting the correct window it will not help you much
Last edited by westconn1; Aug 11th, 2012 at 02:39 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|