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

atabase 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