Go Back   Access World Forums > Microsoft Access Reference > Access FAQs

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
Old 07-29-2009, 07:40 PM   #1
ajetrumpet
Banned
 
Join Date: Jun 2007
Location: Universe - Local Group - Milky Way Galaxy - Orion Arm
Posts: 5,640
Thanks: 0
Thanked 97 Times in 44 Posts
ajetrumpet has a spectacular aura about ajetrumpet has a spectacular aura about
Send a message via MSN to ajetrumpet Send a message via Yahoo to ajetrumpet
Navigate Internet Explorer using VBA

There are certainly a lot of questions out there about the internet and VBA. I use internet explorer quite often with VBA to navigate and perform other various automation tasks. This thread will hopefully give you the basics of navigating the internet with IE through VBA code.


Which browser do I use to read webpage source code?
They're making it easier to read through stuff, but I would recommend using Firefox to read source code. It is formatted in a very friendly way and you can find data very easily. Internet Explorer is very poor and I would not recommend using it unless you have IE8. IE8 has been modified greatly for web developers, and it is probably better for readability and navigation now than Firefox is. It is color coded and line numbered, which is a huge improvement by Microsoft (one of the few for sure!)



First thing to know is how to open IE in Access. Just like any other application, the best way is probably to create the object and make it visible. Like this:
Code:
dim ie as object
set ie = createobject("internetexplorer.application")

ie.visible = true
Navigating from webpage to webpage can be done like this:
Code:
ie.navigate "URL"
After navigating to a page, it is always a good idea to pause the code until the page completely loads. This code will do that after the navigation:
Code:
         While ie.busy
            DoEvents
         Wend
You may also want to manipulate some data while you're browsing the internet. This all has to be done by using HTML code. Some of the tasks I do with it are things like pulling values from pages, populating textboxes, and submitting forms. You can do a number of other things, but these are the most common, at least for me. Here is an outline of how to do each of these:

How do I get a value from a page?
Values are stored in a variety of elements in HTML. They can be in tables, textboxes, links, and others. Regardless of where the target value is, you need to know how to reference an HTML control. The most common way is probably by it's ID. You can get an element's value from it's ID with the following syntax:
Code:
ie.document.getElementById("ELEMENT ID").value
I don't believe there is any easy way to identify elements on a web page other than viewing it's source code. To do this, right click on the page and select "View Source" from the menu:



Then you need to find the ID of the element you want to manipulate. In this above example, the ID of the textbox happens to be "q". So, if there was indeed a value in the search box, you can pull it into Access like this:
Code:
ie.document.getElementById("q").value
the HTML source code that tells us the ID is found by viewing the page source. There you will find this:
Code:
<input autocomplete="off" maxlength=2048 name=q size=55 title="Google Search" value="">
Elements are generally listed in HTML in the order that you see them appear on the page. Therefore, if you're searching for the ID of a textbox, and the page code is 1000 lines long, use the find feature to find some text that you see on the page that is relatively close to the textbox object. In this example, I searched for the phrase "Google Search". I did this because it is the caption (value) of the submit button that is right below the search box that I wanted to find. It just so happens that in the code, the element that comes right before the button's code is the search box! Easily found....

How do I put a value into a texbox?
Say you want to dynamically put a value in the google search box. You would need to use this code:
Code:
ie.document.getElementById("q").value = "My Search Text"
How do I check a checkbox?
Example - you want to opt-in for a mailing list when submitting a form. Chances are, the HTML will look something like:
PHP Code:
<input type="checkbox"name="optin"id="optin" />
<
div id="optinLabel">CLICK HERE TO RECEIVE OUR NEWSLETTERS</div
here is how to usually mark the box (code not tested in VBA, only in an HTML editor Dreamweaver):
PHP Code:
ie.document.getElementById("optin").checked true 
How do I click a radio button?
Here is the way I did it one time:
PHP Code:
ie.document.getElementById("buttonName").value "on" 
How do I click on TABS?
This one is a little bit tricky. From what I can tell, there are plenty of ways to write this sort of stuff. Some websites use javascriipt functions with tab number argument variables, and then use them to run the script that takes you to the tab you want. Other websites will simply create tables that look like tab strips, like this source code shows (this is one table row from the entire table):
PHP Code:
<tr bgcolor="#FFFFFF">
   <
td width="10" valign="top"><div align="center"></div></td>
   <
td colspan="2" valign="top"><a href="../index.html">
      <
img src="../images2/nav_home_up.gif" width="99" 
      
height="30" border="0"></a><a href="../products2/products.htm">
      <
img src="../images2/nav_products_up.gif" width="100" height="30" 
      
border="0"></a><a href="../services2/services.htm">
      <
img src="../images2/nav_services_up.gif" width="100" height="30" 
      
border="0"></a><a href="../learning2/learning.htm">
      <
img src="../images2/nav_learning_up.gif" width="100" height="30" 
      
border="0"></a><a href="index.php">
      <
img src="../images2/nav_forum_down.gif" width="100" height="30" 
      
border="0"></a><a href="../contact2/contact.htm">
      <
img src="../images2/nav_contact_up.gif" width="100" height="30" 
      
border="0"></a></td>
   <
td valign="top">&nbsp;</td>
</
tr
as you can see, what you see on the screen looks like a tap strip, but it's really a bunch of images behind anchors that take you to the different pages. Notice too, that all the images have a 100px width and a 30px height, to make it look uniform. to click on tabs that are actually tables, you have to get the URL behind the tab image and navigate to it.

How do I choose a value in a combo box list?
Combo boxes are usually called SELECT elements in HTML code. Typical syntax will look like this:
PHP Code:
<select 
     style
="min-width:250px" 
     
name="prefixchoice[]" size="5" 
     
multiple="multiple">

<
option value="" selected="selected">(any prefix)</option>
<
option value="-1">(no prefix)</option>
<
option value="Question" class="" >Question</option>
<
option value="Solved" class="" >Solved</option>
<
option value="Tip" class="" >Tip</option
To change the value, you can usually set the value of the combo box by giving it one of its option values, like this:
PHP Code:
ie.document.getElementById("prefixchoice[]").value "Solved" 
I pulled this code from the Search Page's HTML on this forum as an example. So, if you were to run that code, you would be searching for all the threads that have been officially "Solved" (provided you actually pushed the Search button too). List Boxes (multi-select or not) are manipulated the same way.


How do I click a button?
There are a couple of ways to do this. In the google example, the ID of the search button is "btnG". So, in order to search google, you need to click it, like this:
Code:
ie.document.all("btnG").Click
Another way to do the same thing is to submit the parent form of the button. In this case, there is only one form on the page, and the index for HTML forms starts at 0, just like the default option base of an Access array. So, in order to submit the google form by using this method, you would need to use this:
Code:
ie.document.forms(0).submit
In some cases though, these methods are not readily available for any number of reasons. Here is another way to submit a form using the "click" method of the form's button element:
Code:
ie.document.Forms(0).Item("btnG").Click

This is a basic overview of how to get starting navigating the web with VBA. You can also do this sort of stuff with other browsers like Firefox, Netscape, etc... However, it is much too complicated for the scope of this FAQ. And in all reality, it is much easier and more efficient to perform tasks like these with internet explorer, because that program is built into windows, and you can simply retrieve the program object by using the CreateObject method, as with all other Microsoft Office applications in VBA.

<EDIT>

I just had a requirement whereby I had to search 10,000 webpages for some information that was always located in an HTML table. Before this burden was put upon me, I had no idea how to query tables within a webpage, but in order to get paid, I had to figure it out. So....those who are looking at this FAQ can also benefit from what I did. In VBA, you get an HTML's table cell value like this (tag name for a table cell = <td>):
Code:
Dim elTableCells

elTableCells = ie.Document.getElementsByTagName("td")

debug.print elTableCells.innerHTML
For the requirement I had to fulfill, there was one table on every page that I accessed. But...the information in the table cell was quite lengthly. Luckily though, the info that I wanted was always preceeded by a uniform text string: Country: . Thus, I could use VBA's text extraction functions to get the information I was looking for within the table's innerHTML. Below is some of the code I had to use to get the info across pages I had to access:
Code:
do until rs.eof

elTableCells = ie.Document.getElementsByTagName("td")
  rs.Edit
  rs!LOCATION= Trim(Mid(elTableCells.innerHTML, InStr(elTableCells.innerHTML, _
    "<BR><U><EM>Country: </U></EM>: ") + 27, _
    (InStr(elTableCells.innerHTML, "<br><u><em>Director</u></em>:") - 1) - _ 
    (InStr(elTableCells.innerHTML, "<BR><U><EM>Country: </U></EM>: ") + 27)))
  rs.Update

rs.movenext

loop


Last edited by ajetrumpet; 10-24-2009 at 02:06 PM.
ajetrumpet is offline  
The Following 6 Users Say Thank You to ajetrumpet For This Useful Post:
accessuser1023 (06-04-2013), flscotty1 (07-18-2015), hassanogaibi (06-28-2016), MirzaKatar (02-15-2013), MyTech (06-16-2011), Shallo9 (02-07-2012)
Old 10-24-2009, 02:07 PM   #2
ajetrumpet
Banned
 
Join Date: Jun 2007
Location: Universe - Local Group - Milky Way Galaxy - Orion Arm
Posts: 5,640
Thanks: 0
Thanked 97 Times in 44 Posts
ajetrumpet has a spectacular aura about ajetrumpet has a spectacular aura about
Send a message via MSN to ajetrumpet Send a message via Yahoo to ajetrumpet
Navigate Internet Explorer using VBA (continued)

<!-------------------------------------TROUBLE SHOOTING SECTIONS AND OTHER COOL (and Non-Cool) STUFF--------------------------------------->


<TIMING ISSUES WITH COMPLEX EXTRACTION FROM VBA CODE>

Here is something else I wasn't aware of....apparently VBA extraction function are not that fast when things get pretty complex. For example, if I have an HTML <body> on a webpage that is 10,000 characters long, and I need to extract some value out of it that starts at character 2,399 and is 200 characters long, you need to give VBA time to get it. This is totally experiemental, as VBA will tell you if you haven't given it enough time to extract what you're looking for. If you haven't given it enough time to extract what you're looking for, it will get NOTHING, or the return value will be NULL. Here is a project (which is quite long and complicated) in which I had give the VBA an average of 2 seconds to retrieve the values I wanted after using the extraction functions:
Code:
Option Compare Database
Function searchForInformation()

Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("ALL", dbOpenDynaset)

rs.MoveLast
rs.MoveFirst

DoCmd.SetWarnings False

On Error Resume Next

Dim C
Dim startaddress1
Dim endaddress1
Dim startaddress2
Dim endaddress2
Dim phone
Dim sitestart
Dim siteend
Dim startemail
Dim endemail
Dim paystart
Dim payend
Dim servicestart
Dim serviceend
Dim numTDs

Dim StopTime As Variant, Start As Variant

Dim i As Integer
Dim ie As Object
Dim address As String

Set ie = CreateObject("internetexplorer.application")

'ie.Visible = True
'apiShowWindow ie.hWnd, SW_MAXIMIZE

Debug.Print "Start Time: " & Time

Do Until rs.EOF 'FOR "start record number" TO "end record number"

address = rs!URL
Debug.Print "Record number " & CStr(rs.AbsolutePosition + 1) & _
                " currently being processed..."

      ie.navigate address
      
         While ie.busy
            DoEvents
         Wend

numTDs = ie.Document.getElementsByTagName("td").Length
C = ie.Document.body.innerHTML

Start = 0
StopTime = 2000000
   While Start < StopTime
      Start = Start + 1
   Wend
   
startaddress1 = (InStr(C, "Company Address 1</FONT>") + 51)
endaddress1 = (InStr(C, "<TD>&nbsp;&nbsp;&nbsp;&nbsp;</TD>") - 20)

Start = 0
StopTime = 2000000
   While Start < StopTime
      Start = Start + 1
   Wend

If numTDs < 31 Then
   startaddress2 = (InStr(C, "<TD>&nbsp;&nbsp;&nbsp;&nbsp;</TD>") + 50)
Else
   startaddress2 = (InStr(C, Mid(C, (InStr(C, "<TD>Company Phone</TD>") - _
                         90), 90)) + 50)
End If
   
   Start = 0
StopTime = 12000000
   While Start < StopTime
      Start = Start + 1
   Wend

endaddress2 = (InStr(C, "<TD>Company Phone</TD>") - 20)

Start = 0
StopTime = 2000000
   While Start < StopTime
      Start = Start + 1
   Wend

phone = Mid(C, (InStr(C, "<TD>Company Phone</TD>") + 39), 15)

Start = 0
StopTime = 2000000
   While Start < StopTime
      Start = Start + 1
   Wend

startemail = (InStr(C, "Company's General Email</TD>") + 50)
endemail = (InStr(C, "&amp;cc=admin@iahhc.org") - 1)

Start = 0
StopTime = 2000000
   While Start < StopTime
      Start = Start + 1
   Wend

paystart = (InStr(C, "This Organization Accepts:&nbsp;&nbsp;&nbsp;") + 67)
payend = ((InStr(C, "Services Provided&nbsp;&nbsp;&nbsp;") - 47) - 2)

Start = 0
StopTime = 2000000
   While Start < StopTime
      Start = Start + 1
   Wend

servicestart = (InStr(C, "Services Provided&nbsp;&nbsp;&nbsp;") + 58)
serviceend = ((InStr(C, "Counties&nbsp;&nbsp;&nbsp;") - 47) - 2)

Start = 0
StopTime = 2000000
   While Start < StopTime
      Start = Start + 1
   Wend

rs.Edit
rs!address1 = Mid(C, startaddress1, endaddress1 - startaddress1 + 1)
rs!address2 = Mid(C, startaddress2, endaddress2 - startaddress2 + 1)
rs!phone = Trim(phone)
rs!Email = Mid(C, startemail, endemail - startemail + 1)
rs!payment = Mid(C, paystart, payend - paystart + 1)
rs!services = Mid(C, servicestart, serviceend - servicestart + 1)
rs.Update

Start = 0
StopTime = 2000000
   While Start < StopTime
      Start = Start + 1
   Wend

rs.MoveNext
address = rs!URL
Loop

DoCmd.SetWarnings True

ie.Quit
rs.Close
Set ie = Nothing
Set rs = Nothing

Debug.Print vbCr & "End Time: " & Time
Debug.Print vbCr & "Done!"

End Function
as you can see, all of the extractions needed a 2 second break in order to complete the search. the only one that needed 8 seconds was the extra complex extraction inside the IF, ELSE statement. hope this helps in the quest!


TROUBLE SUBMITTING FORMS?

the security on these elements can get really annoying, especially if techniques have been used to "TRY" and deter automation from happening, but not all the bases have been covered (I wonder if I should say that...??). At any rate, if you're trying to submit a form and it's not working no matter what you seem to try, you might have just been thrown into one of the following situations:
*1) you're trying to click a button that's not a button, but really an image
*2) you know you have to click an image to submit the form, but when you click it, nothing happens.
*3) after submitting the form, IE is throwing an error page at you, or you're navigating to a page unrelated to what you're doing
*4) there is no possible way to submit the form with VBA code

if you're in any of the boats listed above, try these remedies:

*1) programmers sometimes use images as submission button "substitutes" so the page doesn't look like it was just slapped on the internet without any class or effort. try clicking the image using its NAME or ID.
*2) rarely will there be a hidden element behind an image, but it does happen. it happened to me once, otherwise I wouldn't be writing this. at any rate, if this is the case, the hidden element will most likely be an <input>. they all have click() events, so you can try to click it (although I doubt this will work). the only other option is to try and submit the parent form.
*3) chances are, you are submitting the wrong form. check the index integer you are using. when there are a lot of forms on a page, I usually find out which one I want and then count all of the <form> tags on the page. that way, I know what the upperbound of the index is, and I can get my form's index by counting from 0 starting at the top of the page's HTML.
*4) if you're reading this one for help, then the company programmers know more than I do about internet security and preventing automated movement


SESSION VARIABLES and TIMING PAGE MOVEMENTS

Yep, I've noticed a problem with this. I was doing some testing on a site where I had a username and password recently and apparently there were security measures in place whereby your login attempts, successful or not, and the time intervals by which they were happening were being logged by the scripts. If the time intervals between the logins and logouts fell in a certain criteria set by the programmers, the next login attempt would yield a "you have been logged out for your security message. Moreover, I got the message just a few other times when perusing through the site, but using the same click stream over and over again. My guess is too, that measures can be taken to identify identical click streams across subsequent session variables. I highly doubt that a lot of companies know how to do this, as the site I'm referring to in this situation is located out in CA in Silicon Valley, so I'm willing to bet that their programmers can easily put Bill Gates to shame (in his early days of doing what he knew best, that is). So...this is just something to also be aware of. If you can't counter it, doing this type of web browsing with code will get pretty annoying and you'll end up wasting a lot of time.


ie.busy / ie.readystate FAIL:

I have noticed that the "busy" and "readystate" properties are not reliable. Sometimes they fail to hold off code execution until a page completely loads. This seems to happen randomly, and I've read a few other posts on the net about other people experiencing the same problem. As I can see, there is no cure for it, but there are workarounds of course. This can get to be a real pain if you're trying to do extraction after a page loads. I did a uniform search today across a few pages (online database), and I came up with this workaround that ALWAYS guaranteed me a complete page load before code execution continued:
PHP Code:
While ie.busy 'WAIT LIKE USUAL
   DoEvents
Wend
      '
51 IS THE TOTAL NUMBER OF LINKS THAT ARE ON EACH PAGE
      
While ie.Document.getElementsByTagName("a").length 51
         DoEvents
      Wend 
The second LOOP guaranteed me the complete loading of the page up to the point that the links were downloaded. This was all the time I needed to wait in this example because I was executing code immediately on the page links only. If I had to extract data from a table on the page, I probably would use something like this instead:
PHP Code:
      While ie.Document.getElementsByTagName("td").length 500
         DoEvents
      Wend 
You can get the total number of any type of element with this code:
PHP Code:
ie.Document.getElementsByTagName("TAG NAME HERE").length 
Another way to combat these property failures, which I now do more often than not, is to check to see if the page has changed or not. If not, the page just might be taking forever to load, in which case you could reload it. Here is some sample code I used once to search through online database pages when I was assigned a session variable by the server:
PHP Code:
For Each link In ie.Document.links
   
If InStr(link.innertext"Next") = 1 Then

      
'NAVIGATE TO THE NEXT PAGE HERE
      PrevAddress = ie.Document.URL

NextPage:
      ie.navigate link
      
         While ie.busy
            DoEvents
         Wend

start = 0
StopTime = 5000000
   While start < StopTime
      start = start + 1
   Wend

'
CHECK TO SEE IF THE PAGE HAS BEEN FULLY LOADED OR NOT.  IF NOTRELOAD THE PAGE
If ie.Document.URL PrevAddress Then
   
GoTo NextPage
End 
If

         
lastpage False
            
Exit For
   
   
End If
Next link 
As you can see in the above example, when I got to the current page I recorded the Address in the PrevAddress variable and then compared it to the URL of the page that I was on after the busy state registered complete. If I was still on the same page, it starts reloading the next page. As far as I know, it works most of the time, at least from what I've experienced.


AN AUTOMATION SAMPLE (email search)

The following functions were used to search out certain businesses in my area using the 411.com online phone directory. The code searches for email addresses that are found within each company's website. In this example, 800 records were found for business and about 200-300 email addresses:
PHP Code:
Option Compare Database

**************DECLARATIONS SECTION****************
Declare Function 
apiShowWindow Lib "user32" Alias "ShowWindow" _
            
(ByVal hWnd As LongByVal nCmdShow As Long) As Long

Global Const SW_MAXIMIZE 3
Global Const SW_SHOWNORMAL 1
Global Const SW_SHOWMINIMIZED 2


Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long_
                                 ByVal hWndInsertAfter 
As Long_
                                 ByVal x 
As Long_
                                 ByVal y 
As Long_
                                 ByVal cx 
As Long_
                                 ByVal cy 
As Long_
                                 ByVal wFlags 
As Long) As Long

Global Const HWND_TOPMOST = -1
Global Const SWP_NOSIZE = &H1
Global Const SWP_NOMOVE = &H2

Private Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long
Dim dwReturn 
As Long

Const SW_HIDE 0
Const SW_SHOWMAXIMIZED 3

Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long_
     ByVal nCmdShow 
As Long) As Long


Function LookupBusinesses()

DoCmd.SetWarnings False

Dim rs 
As Recordset
Set rs 
CurrentDb.OpenRecordset("411"dbOpenDynaset)
Dim rs2 As Recordset
Set rs2 
CurrentDb.OpenRecordset("411new"dbOpenDynaset)

On Error Resume Next

Dim C
Dim link
Dim x 
As Integer
Dim ismail 
As Boolean

Dim StopTime 
As Variantstart As Variant

Dim ie 
As Object
Dim address 
As String

Set ie 
CreateObject("internetexplorer.application")

ismail False
ie
.Visible True
apiShowWindow ie
.hWndSW_MAXIMIZE

address 
"http://411.yellowpages.com/categories/Iowa-City-IA/Services"

      
ie.navigate address
      
         
While ie.busy
            DoEvents
         Wend

start 
0
StopTime 
5000000
   
While start StopTime
      start 
start 1
   Wend

'GET ALL OF THE DIFFERENT BUSINESS LISTINGS FOR "SERVICES" IN THIS BLOCK
For Each C In ie.Document.links
   If InStr(C, "search_terms=Services") > 0 Then
      rs2.AddNew
      rs2!listing = C
      rs2!city = "Iowa City"
      rs2!state = "IA"
      rs2.Update
   End If
Next C

rs2.MoveLast
rs2.MoveFirst

Do Until rs2.EOF

'
ASSUME HERE THAT 30 PAGES IS THE MAXIMUM WE WILL EVER NEED TO LOOP THROUGH...
For 
1 To 30

address 
Left(rs2!listingInStr(rs2!listing"?")) & "page=" CStr(x) & "&" Right(rs2!listingLen(rs2!listing) - InStr(rs2!listing"?"))

      
ie.navigate address
      
         
While ie.busy
            DoEvents
         Wend

start 
0
StopTime 
5000000
   
While start StopTime
      start 
start 1
   Wend
 
If InStr(ie.Document.url"page=") = 0 Then
   
GoTo NextLoop
End 
If

'PICK OUT THE ACTUAL LINKS TO COMPANY WEBSITES ONLY ON THE DIRECTORY PAGES
For Each C In ie.Document.links
   If InStr(C, "http://") > 0 And InStr(C, "?") = 0 And InStr(C.innerhtml, "Visit Web Site") > 0 Then
      rs.AddNew
      rs!listing = C
      rs!city = "Iowa City"
      rs!state = "IA"
      rs!Type = Mid(address, (InStr(address, "-IA/") + 4), (InStr(address, "?") - (InStr(address, "-IA/") + 4)))
      rs.Update
   End If
Next C

Next x

NextLoop:
rs2.MoveNext
Loop

rs.MoveLast
rs.MoveFirst

'
NOW SEARCH FOR THE EMAIL ADDRESSES ON THE COMPANY WEBSITES
Do Until rs.EOF

Debug
.Print "Record " rs.AbsolutePosition " of " rs.RecordCount
ismail 
False
ie
.navigate rs!listing

         
While ie.busy
            DoEvents
         Wend
   
start 
0
StopTime 
10000000
   
While start StopTime
      start 
start 1
   Wend

'CHECK FOR MAIL LINKS ON HOME PAGE
For Each C In ie.Document.links
   If InStr(C, "mailto:") > 0 Then
   ismail = True
      rs.Edit
      rs!email = Right(C, Len(C) - 7)
      rs.Update
         GoTo NextSite
   End If
Next C

'
CHECK FOR A CONTACT PAGE WHERE EMAILS MIGHT BE LOCATED
If ismail False Then

For Each C In ie.Document.links
   
If InStr(C.innerhtml"Contact") > 0 Then
      ismail 
True
         ie
.navigate C
            
GoTo CheckMailLinks
   End 
If
Next C

GoTo NextSite

CheckMailLinks
:
         While 
ie.busy
            DoEvents
         Wend
   
start 
0
StopTime 
10000000
   
While start StopTime
      start 
start 1
   Wend

For Each link In ie.Document.links
   
If InStr(links"mailto:") > 0 Then
      rs
.Edit
      rs
!email Right(linkLen(link) - 7)
      
rs.Update
         
GoTo NextSite
   End 
If
Next link

End 
If

NextSite:
rs.MoveNext
Loop

GoTo cleanup

cleanup
:
DoCmd.RunSQL "DELETE * FROM [411new]"

ie.Quit
rs
.Close
rs2
.Close
Set ie 
Nothing
Set rs 
Nothing
Set rs2 
Nothing

DoCmd
.SetWarnings True

End 
Function 

Last edited by ajetrumpet; 10-25-2009 at 11:52 AM.
ajetrumpet is offline  
The Following User Says Thank You to ajetrumpet For This Useful Post:
hassanogaibi (06-28-2016)
Old 11-11-2009, 11:25 PM   #3
ajetrumpet
Banned
 
Join Date: Jun 2007
Location: Universe - Local Group - Milky Way Galaxy - Orion Arm
Posts: 5,640
Thanks: 0
Thanked 97 Times in 44 Posts
ajetrumpet has a spectacular aura about ajetrumpet has a spectacular aura about
Send a message via MSN to ajetrumpet Send a message via Yahoo to ajetrumpet
Re: Navigate Internet Explorer using VBA

Here are some useful properties of the internet explorer document object that may be of some use as well:
Code:
with ie.document

    Debug.Print "URL = " & .url
    Debug.Print "DOMAIN = " & .domain
    Debug.Print "REFERRER = " & .referrer
    Debug.Print "PROTOCOL = " & .protocol
    Debug.Print "DATE LAST MODIFIED = " & .LastModified
    Debug.Print "LOCATION = " & .location
    Debug.Print "FILE CREATED ON: " & .fileCreatedDate
    Debug.Print "FILE UPDATED ON: " & .fileUpdatedDate
    Debug.Print "FILE MODIFIED ON: " & .fileModifiedDate
    Debug.Print "FILE SIZE = " & .fileSize

end with
All of these and the rest can be found in the MS HTML Object Library in Access references.

ajetrumpet is offline  
The Following User Says Thank You to ajetrumpet For This Useful Post:
hassanogaibi (06-28-2016)
Old 06-15-2010, 07:01 PM   #4
ajetrumpet
Banned
 
Join Date: Jun 2007
Location: Universe - Local Group - Milky Way Galaxy - Orion Arm
Posts: 5,640
Thanks: 0
Thanked 97 Times in 44 Posts
ajetrumpet has a spectacular aura about ajetrumpet has a spectacular aura about
Send a message via MSN to ajetrumpet Send a message via Yahoo to ajetrumpet
Internet Explorer VBA Library / Elements

The library address for IE and the DOM is: C:\Windows\System32\shDocVw.dll

I don't know if this is automatically listed in references, but if it's not you can certainly add it. If you want a list of elements and attributes for IE, you can find a complete list here: http://www.w3schools.com/jsref/default.asp
ajetrumpet is offline  
The Following User Says Thank You to ajetrumpet For This Useful Post:
hassanogaibi (06-28-2016)
Old 08-11-2010, 09:00 AM   #5
iworkonline
Newly Registered User
 
Join Date: May 2010
Posts: 44
Thanks: 0
Thanked 2 Times in 2 Posts
iworkonline is on a distinguished road
Re: Navigate Internet Explorer using VBA

The website is a password protected website. So the user first logs in the site and then use the web based application by entering the shipper number and then it generates some results. At this point I want the user to click a button on the Access form that will extract the data from the webpage and copy over in Access tables.

How do I reference the already opened IE Window. Plus I have multiple IE windows open.

I am using a pretty old IE version 6.0

Thanks.


Last edited by iworkonline; 08-11-2010 at 09:16 AM.
iworkonline is offline  
The Following User Says Thank You to iworkonline For This Useful Post:
hassanogaibi (06-28-2016)
Closed Thread

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Introduction to VBA Programming Banana Access FAQs 0 10-30-2008 06:11 PM
Get Url address from Internet explorer prometro Modules & VBA 1 08-18-2008 01:33 PM
is it possible to create a help file which opens internet explorer sunilvedula Modules & VBA 2 03-01-2007 06:55 AM
Navigate a Query BernardAtherton Modules & VBA 27 03-18-2004 08:03 PM




All times are GMT -8. The time now is 06:06 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World