S
SF
Hi,
I have a contract database that allow me to query data from the database and
merge it to word file. The code below seem to work OK except that It does
export the whole contract information to excel first and then doing the
merge.
Is there a way to only limite the export to just one record (preferable a
select record by contract number) to excel before doing the merge?
Private Sub Command26_Click()
Dim Stg As String
Dim strDocName As String
Dim appWord As Word.Application
Dim docWord As Word.Document
Dim strFilePath As String
DoCmd.OutputTo acOutputQuery, "rptContracts", acFormatXLS,
"C:\PIC\CONTRACT.XLS"
strFilePath = "C:\PIC\WORD\Sub Grant Agreement.DOC"
Set objWord = GetObject(strFilePath, "Word.document")
objWord.Application.Visible = True
objWord.MailMerge.Execute ' execute the mail merge
objWord.ActiveDocument.PrintOut Background:=False
objWord.ActiveDocument.Close wdDoNotSaveChanges
'objWord.Close
'AbortPrint:
' appWord.Quit
' Set docWord = Nothing
' Set appWord = Nothing
' Set rstPrintDone = Nothing
End Sub
SF
I have a contract database that allow me to query data from the database and
merge it to word file. The code below seem to work OK except that It does
export the whole contract information to excel first and then doing the
merge.
Is there a way to only limite the export to just one record (preferable a
select record by contract number) to excel before doing the merge?
Private Sub Command26_Click()
Dim Stg As String
Dim strDocName As String
Dim appWord As Word.Application
Dim docWord As Word.Document
Dim strFilePath As String
DoCmd.OutputTo acOutputQuery, "rptContracts", acFormatXLS,
"C:\PIC\CONTRACT.XLS"
strFilePath = "C:\PIC\WORD\Sub Grant Agreement.DOC"
Set objWord = GetObject(strFilePath, "Word.document")
objWord.Application.Visible = True
objWord.MailMerge.Execute ' execute the mail merge
objWord.ActiveDocument.PrintOut Background:=False
objWord.ActiveDocument.Close wdDoNotSaveChanges
'objWord.Close
'AbortPrint:
' appWord.Quit
' Set docWord = Nothing
' Set appWord = Nothing
' Set rstPrintDone = Nothing
End Sub
SF