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 the mailmerge process a security warning 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 changes to
this database objects in the database the MyDB....Thus 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 Windows. I need to deploy this program on machine that does not have
Access.
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 x As String
'Fn is the filename of the merging template
'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:\MyFolder\MyDB.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
Please help!!!!!
-Ralph
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 the mailmerge process a security warning 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 changes to
this database objects in the database the MyDB....Thus 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 Windows. I need to deploy this program on machine that does not have
Access.
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 x As String
'Fn is the filename of the merging template
'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:\MyFolder\MyDB.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
Please help!!!!!
-Ralph