W
Worksmart
I'm using Word 2003 for merge documents. Excel 2003 is DataSource. Outlook
2003 for email. Windows Vista Home Premium.
I am not a programmer and am piecing together different macros.
I'm creating a dashboard (Word table) that will allow me to launch a macro
to create a set of documents via mail merge. Everything is working except the
following.
I've created a CommandButton to create mail merge email messages. This is
what happens:
Click CommandButton to start the merge
Are you sure? Yes
Choose Template to use in the merge
Choose DataSource
Enter Subject Line, OK
Choose Recipients, OK
Then this is where the problem comes in. This "Allow Access" box comes up
and I allow access for 10 minutes.
Then for every recipient, another box comes up with "A program is trying to
automatically send email on your behalf...."
I'm having to wait and click Yes for each name. There has to be a way to
stop all this.
Also, my subject line isn't showing up in the message.
When I create the message in Word without using the CommandButton...just
regular mail merge steps, none of this happens.
Here is my code (I'm not a programmer)
Private Sub CommandButton4_Click()
' Events_Email Macro
' Macro recorded 5/11/2008 by Peggy Duncan
'
If MsgBox(Prompt:="Are You Sure?", Buttons:=vbYesNo + vbQuestion, _
Title:="Mail Merge Document") = vbNo Then
Exit Sub
End If
' Check if Outlook is running. If it is not, start Outlook
On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
Dialogs(wdDialogFileOpen).Show
With ActiveDocument.MailMerge
' Show an input box asking the user for the subject to be inserted
into the email messages
Message = "Enter Your Subject Line for this Message." ' Set prompt.
Title = " Email Subject Input - Make it read like a headline" ' Set title.
' Display message, title
mysubject = InputBox(Message, Title)
.MailAddressFieldName = "Email"
Dialogs(wdDialogMailMergeRecipients).Display
.Destination = wdSendToEmail
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
'
' Close Outlook if it was started by this macro.
If bStarted Then
oOutlookApp.Quit
End If
'Clean up
Set oOutlookApp = Nothing
Source.Close wdDoNotSaveChanges
Maillist.Close wdDoNotSaveChanges
End Sub
Does anyone have any ideas about how to fix this. Thanks in advance.
2003 for email. Windows Vista Home Premium.
I am not a programmer and am piecing together different macros.
I'm creating a dashboard (Word table) that will allow me to launch a macro
to create a set of documents via mail merge. Everything is working except the
following.
I've created a CommandButton to create mail merge email messages. This is
what happens:
Click CommandButton to start the merge
Are you sure? Yes
Choose Template to use in the merge
Choose DataSource
Enter Subject Line, OK
Choose Recipients, OK
Then this is where the problem comes in. This "Allow Access" box comes up
and I allow access for 10 minutes.
Then for every recipient, another box comes up with "A program is trying to
automatically send email on your behalf...."
I'm having to wait and click Yes for each name. There has to be a way to
stop all this.
Also, my subject line isn't showing up in the message.
When I create the message in Word without using the CommandButton...just
regular mail merge steps, none of this happens.
Here is my code (I'm not a programmer)
Private Sub CommandButton4_Click()
' Events_Email Macro
' Macro recorded 5/11/2008 by Peggy Duncan
'
If MsgBox(Prompt:="Are You Sure?", Buttons:=vbYesNo + vbQuestion, _
Title:="Mail Merge Document") = vbNo Then
Exit Sub
End If
' Check if Outlook is running. If it is not, start Outlook
On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
Dialogs(wdDialogFileOpen).Show
With ActiveDocument.MailMerge
' Show an input box asking the user for the subject to be inserted
into the email messages
Message = "Enter Your Subject Line for this Message." ' Set prompt.
Title = " Email Subject Input - Make it read like a headline" ' Set title.
' Display message, title
mysubject = InputBox(Message, Title)
.MailAddressFieldName = "Email"
Dialogs(wdDialogMailMergeRecipients).Display
.Destination = wdSendToEmail
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
'
' Close Outlook if it was started by this macro.
If bStarted Then
oOutlookApp.Quit
End If
'Clean up
Set oOutlookApp = Nothing
Source.Close wdDoNotSaveChanges
Maillist.Close wdDoNotSaveChanges
End Sub
Does anyone have any ideas about how to fix this. Thanks in advance.