Hi Guys,
I have the following code to merge a word document and the results of a query (code and Job Title) which works fine.
Set WordApp = New Word.Application
If (Me.TxtQA.Value = "Safe Increase") Or (Me.TxtQA.Value = "Unsafe Increase") Then
Set WordDoc = WordApp.Documents.Open(FileName:="X:\ReviewOutcomes\Review letters\Review outcome increase letter.doc", _
ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
wdOpenFormatAuto)
Set WordMerge = WordDoc.MailMerge
WordMerge.OpenDataSource _
Name:=CurrentProject().FullName, _
LinkToSource:=True, AddToRecentFiles:=False, _
SQLStatement:="SELECT * From[QueryReviewOutcomeMerge]"
With WordMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
Set WordMerge = Nothing
WordDoc.Close
Set WordDoc = Nothing
WordApp.Visible = True
What I would also like to do is add the results of another query (a list of staff names attached to the code) into the merge but I can't work out how to do it.
As always any help on this would be greatly appreciated.
I have the following code to merge a word document and the results of a query (code and Job Title) which works fine.
Set WordApp = New Word.Application
If (Me.TxtQA.Value = "Safe Increase") Or (Me.TxtQA.Value = "Unsafe Increase") Then
Set WordDoc = WordApp.Documents.Open(FileName:="X:\ReviewOutcomes\Review letters\Review outcome increase letter.doc", _
ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
wdOpenFormatAuto)
Set WordMerge = WordDoc.MailMerge
WordMerge.OpenDataSource _
Name:=CurrentProject().FullName, _
LinkToSource:=True, AddToRecentFiles:=False, _
SQLStatement:="SELECT * From[QueryReviewOutcomeMerge]"
With WordMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
Set WordMerge = Nothing
WordDoc.Close
Set WordDoc = Nothing
WordApp.Visible = True
What I would also like to do is add the results of another query (a list of staff names attached to the code) into the merge but I can't work out how to do it.
As always any help on this would be greatly appreciated.