Disable MS Outlook message when accessing email addresses

lukeshuttlewood

Board Regular
Joined
Jul 27, 2004
Messages
90
Hi,

Some time a ago I found and used some code that grabs the users email address from outlook. This all worked smoothly until office was upgraded to security conscious 2003.

When I run the following code in Office Excel 2003:

Code:
    On Error GoTo Error1
    Dim myOlApp As Object
    Dim myNameSpace As Object
    
    Set myOlApp = CreateObject("Outlook.Application")
    Set myNameSpace = myOlApp.GetNamespace("MAPI")
    
    Emailaddress = myNameSpace.CurrentUser.Name
    GoTo Success
Error1:
    Emailaddress = "Could not get username"
Success:

I get this message prompt:

A programme is trying to access email addresses you have stored in outlook. Do you want to allow this?

If this is unexpected, it may be a virus and you should choose "No".

YES / NO



I had a snoop at the thread below which seems to address a very similar problem:

http://www.mrexcel.com/board2/viewtopic.php?t=167779&highlight=cdo

Apparently its the 'SendKeys "%{s}", True' that has the desired effect but this as it stands doesnt work for the code im using!

Does anyone know how I can adapt this to suit my needs?

Many thanks
Luke[/code]
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,215,500
Messages
6,125,168
Members
449,211
Latest member
ykrcory

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top