Word Automating MailMerge Problem

R

Roplab

Hi Everyone,
I created a macro package for authomating MailMerge in MSWord 2003 the
program worked fine but the problem that I am having is that during
mailmerge process as security warnning popup("openning "D:\MyDB" This file
may not be safe if it contains code that was intended to harm your computer.
Do you want to open this file or cancel the operation) and if I click open
it brings another popup saying that ("You can't make change to this database
the MyDB..This Database was create in an earlier version of microsoft
Access.....") and if I deploy the template to a machine that does not have
Microsoft Access, I get a Select Table Window. I need to deploy this
template on a machine that does not have Microsoft Access. Please any help
or advice will be appreciated.

BELOW IS THE CODE THAT I AM USING:

Private Sub cmdOK_Click()
On Error GoTo Para_InitError

Dim oWord As Word.Documents
Dim strTable As String
Dim CntStr As String
Dim Sqlstr As String
Dim MyMerge As Word.MailMerge
'Dim Str As String
Dim x As String


'Str = "D:\FCMerge\FCMerge.mdb"

'Hide active form
Me.Hide
Documents.Open FileName:=Fn, ReadOnly:=True, AddToRecentFiles:=False
strTable = lsbParalegal.Value
CntStr = "TABLE " & strTable
Sqlstr = "SELECT * FROM " & strTable & " WHERE " _
& "(((" & strTable & ".ID)=" _
& lsbFiles.Value & "))"

Set MyMerge = ActiveDocument.MailMerge
With MyMerge
.MainDocumentType = wdFormLetters
.OpenDataSource Name:="D:\FCMerge\FCMerge.mdb", Connection:=CntStr,
SQLSTATEMENT:=Sqlstr, _
SubType:=wdMergeSubTypeWord2000, ReadOnly:=True, LinkToSource:=True,
openExclusive:=True

End With

If MyMerge.State = wdMainAndDataSource Then
MyMerge.Application.DisplayAlerts = wdAlertsNone
MyMerge.Destination = wdSendToNewDocument
MyMerge.Application.Visible = True
MyMerge.Execute pause:=False

x = ActiveDocument.Name
Documents(Fn).Close wdDoNotSaveChanges

Documents(x).Activate
Application.ScreenUpdating = True

End If

Err_handler:
Exit Sub
Para_InitError:
MsgBox "Error No: " & Err.Number & "; error message: " & Err.Description
Resume Err_handler
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top