code to bypass security

M

Michelle Hanan

I am running a macro in excel that email merges through Outlook 07. I would
like to find code to avoid getting the "a program is trying to access email
address information stored in Outlook" message. Is there such?
 
M

Michelle Hanan

Ok, so I'm a little confused. Which code do I use and where should I insert
it into my macro?
Here's the email merge portion of my macro:

myDoc.MailMerge.MainDocumentType = wdEMail
myDoc.MailMerge.OpenDataSource Name:= _
"\\powervault2\home_pl\common\Email\Referals.xls", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
_
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
_
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data
Source=\\powervault2\home_pl\common\Email\Referals.xls;Mode=Read;Extended
Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet
OLEDB:Registry Path="""";Jet OLEDB:Database Pa" _
, SQLStatement:="SELECT * FROM `Sheet1$`", SQLStatement1:="",
SubType:= _
wdMergeSubTypeAccess
With myDoc.MailMerge
.Destination = wdSendToEmail
.MailAddressFieldName = "Address"
.MailSubject = "Referals"
.MailAsAttachment = True
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
myDoc.Close wdDoNotSaveChanges
End Sub
 
S

Sue Mosher [MVP-Outlook]

Your options are limited because you are not technically doing Outlook automation at all. If you want to stick with that code, you'd have to use one of the tools on the page Dmitry suggested that suppresses the prompts. If, on the other hand, you want the prompts to disappear completely, with Outlook 2007 and an up-to-date anti-virus application running on your system, you will get no prompts if you use the Outlook object model directly in your code.

It's up to you now to decide whether it's worth the effort to rewrite the code to use the Outlook object model or use one of the utilities on the page Dmitry suggested.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
M

Michelle Hanan

I think the easiest way would be to insert the code because I'm not doing
the outlook automation. Although I am still confused where I would put that
particular line of code: objMailItem.To = [email protected] to
suppress the security prompt.

Here is my whole macro that I am trying to run.....

Sub Ecology()
'This first macro opens word for the rest of the macros. It also merges data
from Referals.xls, worksheet one, into different merge fields on the
document stated in the macro.
Dim wdApp As Object
Dim myDoc As Word.Document
Set wdApp = CreateObject("Word.Application")
Set myDoc = Word.Documents.Open("\\powervault2\home_pl\common\Email\Referal
Agency - Ecology.doc")
myDoc.MailMerge.MainDocumentType = wdEMail
myDoc.MailMerge.OpenDataSource Name:= _
"\\powervault2\home_pl\common\Email\Referals.xls", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
_
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
_
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data
Source=\\powervault2\home_pl\common\Email\Referals.xls;Mode=Read;Extended
Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet
OLEDB:Registry Path="""";Jet OLEDB:Database Pa" _
, SQLStatement:="SELECT * FROM `Sheet1$`", SQLStatement1:="",
SubType:= _
wdMergeSubTypeAccess
With myDoc.MailMerge
.Destination = wdSendToEmail
.MailAddressFieldName = "Address"
.MailSubject = "Referals"
.MailAsAttachment = True
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
myDoc.Close wdDoNotSaveChanges
End Sub





Your options are limited because you are not technically doing Outlook
automation at all. If you want to stick with that code, you'd have to use
one of the tools on the page Dmitry suggested that suppresses the prompts.
If, on the other hand, you want the prompts to disappear completely, with
Outlook 2007 and an up-to-date anti-virus application running on your
system, you will get no prompts if you use the Outlook object model directly
in your code.

It's up to you now to decide whether it's worth the effort to rewrite the
code to use the Outlook object model or use one of the utilities on the page
Dmitry suggested.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

Setting the value of objMailItem.To would never raise a security prompt. This is not a simple "insert the code" project. You would have to complete rewrite the code in two phases:

1) Perform a merge to create and save individual Word documents

2) For each document created in the merge, create and send an individual Outlook MailItem (message). The MailItem.Send method would trigger a security prompt unless the code is running in Outlook or you use Redemption or one of the other approaches listed on the page suggested.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Top