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? - Function getEmail(enumber As String)
-
Dim url As String
-
Dim IE As InternetExplorer
-
Dim HTMLDoc As HTMLDocument
-
Dim html As String
-
Dim atLocation As Long, startLocation As Long, endLocation As Long
-
Dim x As Long
-
-
'Create a new instance of Internet Explorer
-
Set IE = Nothing
-
Set IE = New InternetExplorer
-
-
'Define the URL we will be loading
-
url = "http://people.aflacworkplace.com//Person.aspx?accountname=AFLHQ\" & enumber
-
-
'Ensure that the IE Window is hidden and navigate to the website defined above
-
IE.Visible = False
-
IE.navigate url
-
-
'Loop until the website is completely loaded...
-
Do While IE.Busy Or IE.readyState <> READYSTATE_COMPLETE
-
DoEvents
-
Loop
-
-
'Save the html behind the page we are on to a variable (html) and determine which character contains the first @
-
html = IE.Document.body.outerHTML
-
atLocation = InStr(1, html, "@")
-
-
'Loop backwards from the "@" location to find the opening ":" (the E-Mail address is first listed in the html as 'email@aflac.com')
-
For x = atLocation To 0 Step -1
-
If Mid(html, x, 1) = ":" Then
-
startLocation = x + 1
-
Exit For
-
End If
-
Next
-
-
'Loop forwards from the "@" location to find the closing "'"
-
For x = atLocation To (atLocation + 100) Step 1
-
If Mid(html, x, 1) = "'" Then
-
endLocation = x
-
Exit For
-
End If
-
Next
-
-
'Close IE and Destroy Object
-
IE.Quit
-
Set IE = Nothing
-
-
'Return Value
-
getEmail = Mid(html, startLocation, endLocation - startLocation)
-
End Function
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
Try CreateObject("InternetExplorer.Application")
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.
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?
Which line does the debugger point to when it errors, and whats the exact error number and description.
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?
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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
|
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...
|
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...
|
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...
|
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....
|
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...
|
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...
|
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...
|
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...
|
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
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| |