473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Calling IE with access 2007 vba

this code worked in access 97 and i am getting an error on the internet explorer variable. Is there an updated way of having vba open this program?

Expand|Select|Wrap|Line Numbers
  1. Function getEmail(enumber As String)
  2. Dim url As String
  3. Dim IE As InternetExplorer
  4. Dim HTMLDoc As HTMLDocument
  5. Dim html As String
  6. Dim atLocation As Long, startLocation As Long, endLocation As Long
  7. Dim x As Long
  8.  
  9. 'Create a new instance of Internet Explorer
  10. Set IE = Nothing
  11. Set IE = New InternetExplorer
  12.  
  13. 'Define the URL we will be loading
  14. url = "http://people.aflacworkplace.com//Person.aspx?accountname=AFLHQ\" & enumber
  15.  
  16. 'Ensure that the IE Window is hidden and navigate to the website defined above
  17. IE.Visible = False
  18. IE.navigate url
  19.  
  20. 'Loop until the website is completely loaded...
  21. Do While IE.Busy Or IE.readyState <> READYSTATE_COMPLETE
  22.     DoEvents
  23. Loop
  24.  
  25. 'Save the html behind the page we are on to a variable (html) and determine which character contains the first @
  26. html = IE.Document.body.outerHTML
  27. atLocation = InStr(1, html, "@")
  28.  
  29. 'Loop backwards from the "@" location to find the opening ":" (the E-Mail address is first listed in the html as 'email@aflac.com')
  30. For x = atLocation To 0 Step -1
  31.     If Mid(html, x, 1) = ":" Then
  32.         startLocation = x + 1
  33.         Exit For
  34.     End If
  35. Next
  36.  
  37. 'Loop forwards from the "@" location to find the closing "'"
  38. For x = atLocation To (atLocation + 100) Step 1
  39.     If Mid(html, x, 1) = "'" Then
  40.         endLocation = x
  41.         Exit For
  42.     End If
  43. Next
  44.  
  45. 'Close IE and Destroy Object
  46. IE.Quit
  47. Set IE = Nothing
  48.  
  49. 'Return Value
  50. getEmail = Mid(html, startLocation, endLocation - startLocation)
  51. End Function
Mar 7 '11 #1

✓ answered by Rabbit

That line doesn't exist in your code. You have dim htmldoc as HTMLdocument but not dim html as HTMLdocument. You're not even using the htmldoc variable so you can get rid of that line.

6 3946
Rabbit
12,516 Expert Mod 8TB
Try CreateObject("InternetExplorer.Application")
Mar 7 '11 #2
It seems like most of this doesn’t really work, and the problem is focused around actually successfully calling IE and opening the source.

maybe you can offer a better process for getting this done.


What im doing is pulling the id number of the logged in user, accessing the active directory via internet explorer, converting the webpage to the source, storing it in an html document, searching for the @, and generating an email(separate module)
I am not the original author of this code and am not a vba expert at all. fixing this is a bit above my head.
Mar 8 '11 #3
Rabbit
12,516 Expert Mod 8TB
Well, you're trying to pull data from Active Directory, you could use an LDAP query.

The url string looks like it is incorrectly formatted. Have you tried outputting the string and then attempting to go to the url directly?
Mar 8 '11 #4
TheSmileyCoder
2,322 Expert Mod 2GB
Which line does the debugger point to when it errors, and whats the exact error number and description.
Mar 8 '11 #5
its stopping at "dim html as HTMLdocument"
i cant find the correct reference to add within the menu.
Is there a way I can install it manually?
Mar 9 '11 #6
Rabbit
12,516 Expert Mod 8TB
That line doesn't exist in your code. You have dim htmldoc as HTMLdocument but not dim html as HTMLdocument. You're not even using the htmldoc variable so you can get rid of that line.
Mar 9 '11 #7

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

Similar topics

27
by: Wayne | last post by:
I've been clicking around Access 2007 Beta 2 and can't see the custom menu bar designer. Is it in the beta? Maybe I'm blind. The question that comes to mind is: Will custom menu bars be the same...
1
by: Bob Alston | last post by:
Anyone know of any features of the new Access 2007 that will improve on the ability of Access to work in a web environment??? Bob
1
prn
by: prn | last post by:
Hi folks, I'm relatively new to Access, but I seem to have drawn the short straw, so I have the assignment for my workplace of looking for problems/inconsistencies in migrating applications to...
17
by: Neil | last post by:
A client of mine likes some of the new bells and whistles in Access 2007, and is thinking about converting our A03 format MDB to an A07 format file. However, while some of the users have A07, many...
1
by: ishwarjoshi | last post by:
I am in the process of upgrading an old Access ADP/SQL 2000 App to Access 2007 ADP/SQL 2005. There are a lot of buttons in the Access form which are calling Access Macros, the Macros call...
5
by: lgeastwood | last post by:
I have a weird problem in Access 2007. I've been working in A07 for about 2 weeks when this thing began occurring. I'm working in the VB Code Editor and set break points for event procedures....
10
by: Arno R | last post by:
Hi all, So I bought a new laptop 10 days ago to test my apps with Vista. (home premium) Apparently Office 2007 is pre-installed. (a time limited but complete test version, no SP1) So I take the...
4
by: jackbenimble999 | last post by:
Hello! Has anyone had trouble running macros on the Access runtime version on Vista? I tried enabling macros in the trust center, and thought for sure this would solve the problem! But, alas, my...
9
by: prakashwadhwani | last post by:
Hi !! I'm about to develop a new project for a client. Should I go about it in Access 2003 or 2007 ? Purchasing it either for me or for my client is not a major consideration here ... what I'd...
1
by: ARC | last post by:
I think I made a major blunder, and now Access 2007 no longer opens. I made the mistake yesterday of using the "test" option in wise installer for my Access 2007 runtime app. It actually installed...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.