Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Merging Access data into a Word document
Is it possible to take the data from Access, and merge it into just one Word
document? I wish to create a form letter addressed to one person, using the data that I have stored in an Access database. However, the only options I have discovered so far are to either create a mass-mailing, or to create a poorly formatted report in Access, then use the "publish it" function. This outputs again a poorly formatted document. Is it possible for me to design a form letter in Word, and have it pull the data for just one letter, rather than 100? |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Merging Access data into a Word document
See the "Super Easy Word Merge" item at
http://www.members.shaw.ca/AlbertKal.../msaccess.html -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Danny" wrote in message ... Is it possible to take the data from Access, and merge it into just one Word document? I wish to create a form letter addressed to one person, using the data that I have stored in an Access database. However, the only options I have discovered so far are to either create a mass-mailing, or to create a poorly formatted report in Access, then use the "publish it" function. This outputs again a poorly formatted document. Is it possible for me to design a form letter in Word, and have it pull the data for just one letter, rather than 100? |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Merging Access data into a Word document
I am using this piece of code and am having a little problem with my
mergefields not picking up the correct value for a YES/NO field. If I use {mergefield name ="false" ...} it doesn't work with single records but does when I use all records. BUT .. When I use {mergefield name = "0" ..} it works for single records but not for all records. Whichever way I go, I can't seem to get the word template to pay ball correctly whether I use a single record or merge all records. Has anyone else come across this, and if so, how was it resolved? Regards Gary "Doug Robbins - Word MVP" wrote: See the "Super Easy Word Merge" item at http://www.members.shaw.ca/AlbertKal.../msaccess.html -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Merging Access data into a Word document
What exactly does {Mergefield name} produce when inserted without a condition? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org GaryNSHC wrote: I am using this piece of code and am having a little problem with my mergefields not picking up the correct value for a YES/NO field. If I use {mergefield name ="false" ...} it doesn't work with single records but does when I use all records. BUT .. When I use {mergefield name = "0" ..} it works for single records but not for all records. Whichever way I go, I can't seem to get the word template to pay ball correctly whether I use a single record or merge all records. Has anyone else come across this, and if so, how was it resolved? Regards Gary "Doug Robbins - Word MVP" wrote: See the "Super Easy Word Merge" item at http://www.members.shaw.ca/AlbertKal.../msaccess.html -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP |
#5
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Merging Access data into a Word document
My apologies, I am using an IF condition as well as a MERGEFIELD.
The one which works in a single record is: {IF {mergefield MAACTeam} = "0", "No", "Yes"} and I get "NO" if I change = "0" to either = "TRUE" or = "FALSE" I get "YES" which is incorrect. The one which works for all records is: {IF {mergefield MAACTeam} = "FALSE", "No", "Yes"} I get either "YES" or "NO" if I change = "FALSE" to either = "0" or = "-1" I get "YES" for all records which is incorrect. If I have just: {mergefield MAACTeam} I get either "0" or "-1" depending on whether it should be "YES" or "NO". Hope this clarifies the problem being encountered. Regards Gary "Graham Mayor" wrote: What exactly does {Mergefield name} produce when inserted without a condition? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org GaryNSHC wrote: I am using this piece of code and am having a little problem with my mergefields not picking up the correct value for a YES/NO field. If I use {mergefield name ="false" ...} it doesn't work with single records but does when I use all records. BUT .. When I use {mergefield name = "0" ..} it works for single records but not for all records. Whichever way I go, I can't seem to get the word template to pay ball correctly whether I use a single record or merge all records. Has anyone else come across this, and if so, how was it resolved? Regards Gary "Doug Robbins - Word MVP" wrote: See the "Super Easy Word Merge" item at http://www.members.shaw.ca/AlbertKal.../msaccess.html -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP |
#6
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Merging Access data into a Word document
If I have just:
{mergefield MAACTeam} I get either "0" or "-1" depending on whether it should be "YES" or "NO". Is this actually -1 for Yes and 0 for No (in which case are you using Word 2000 or earlier and/or connecting using DDE? AFAIK the values Word receives are as follows: Connection method "Yes" "No" DDE -1 0 ODBC 0 1 OLE DB True False When you say "works for a single record" what are you doing differently? Do you mean you are connecting to a different data source that only has one record, are you using the same table/query as the data source in both merges and changing the query criteria for one of them? Or what? Also, are the Yes/No results for just { mergefield MAACTeam } always -1 and 0, or do they actually differ depending on whehter you are doing 1 record or many records? Also, are you really using "FALSE" rather than "False"? Can we assume that you have not got commas in your IF field? Do you have a bookmark called False in your Mail Merge Main Document or any included file? Does it make any difference if you quote the mergefield, e.g. { IF "{ MERGEFIELD MAACTeam }" = "0" "No" "Yes" } Peter Jamieson "GaryNSHC" wrote in message ... My apologies, I am using an IF condition as well as a MERGEFIELD. The one which works in a single record is: {IF {mergefield MAACTeam} = "0", "No", "Yes"} and I get "NO" if I change = "0" to either = "TRUE" or = "FALSE" I get "YES" which is incorrect. The one which works for all records is: {IF {mergefield MAACTeam} = "FALSE", "No", "Yes"} I get either "YES" or "NO" if I change = "FALSE" to either = "0" or = "-1" I get "YES" for all records which is incorrect. If I have just: {mergefield MAACTeam} I get either "0" or "-1" depending on whether it should be "YES" or "NO". Hope this clarifies the problem being encountered. Regards Gary "Graham Mayor" wrote: What exactly does {Mergefield name} produce when inserted without a condition? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org GaryNSHC wrote: I am using this piece of code and am having a little problem with my mergefields not picking up the correct value for a YES/NO field. If I use {mergefield name ="false" ...} it doesn't work with single records but does when I use all records. BUT .. When I use {mergefield name = "0" ..} it works for single records but not for all records. Whichever way I go, I can't seem to get the word template to pay ball correctly whether I use a single record or merge all records. Has anyone else come across this, and if so, how was it resolved? Regards Gary "Doug Robbins - Word MVP" wrote: See the "Super Easy Word Merge" item at http://www.members.shaw.ca/AlbertKal.../msaccess.html -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP |
#7
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Merging Access data into a Word document
Hi all,
Whilst probably not the most elegant solution, what I have found that works is a "double if" function which checks whether the value is "0" first, if so then it will display "No", if the value is not "0", a second if function will determine if the value is "false" and display "No", otherwise it will display "Yes". Regards Gary "GaryNSHC" wrote: I am using this piece of code and am having a little problem with my mergefields not picking up the correct value for a YES/NO field. If I use {mergefield name ="false" ...} it doesn't work with single records but does when I use all records. BUT .. When I use {mergefield name = "0" ..} it works for single records but not for all records. Whichever way I go, I can't seem to get the word template to pay ball correctly whether I use a single record or merge all records. Has anyone else come across this, and if so, how was it resolved? Regards Gary "Doug Robbins - Word MVP" wrote: See the "Super Easy Word Merge" item at http://www.members.shaw.ca/AlbertKal.../msaccess.html -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP |
#8
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Merging Access data into a Word document
The solution depends on what level of automation that you need.
In Word 2003, you can use Tools Letters/Mailings Mail Merge, and after selecting the Access table in step 3, check only the one recipient that you want. You may also try Albert Kallal's "MergeSingleWord". http://www.members.shaw.ca/AlbertKal.../msaccess.html I automated the process with Visual Basic code to merge the current record being displayed on an Access form. The form has fields to find and identify the desired record, a command button to launch this code, and a text box bound the data table primary key called OrderID. This article was used as a foundation: http://support.microsoft.com/?id=209976 The code requires reference (Tools References) to Word 11 Object Library; may need to browse for C:\PF\MS Office\Office11\msword.olb The Word template should not be bound to a data source. Bind it to a data source only to easily enter the merge fields, then convert it back to a normal Word document (Word 2000: Mail Merge Helper 1 Restore to normal Word document. Word 2003: Mail merge toolbar Main document setup Normal Word document). You may get errors from Word such as the "Data Link" window or complaints that Access is locked and needs an admin password. Post them to this thread. Here is the code. Any MVPs and pros, feel free to correct. Sorry for line wrapping; not sure why it does that. Function OutputDoc() Dim appWord As Word.Application Dim objWord As Word.Document Set appWord = New Word.Application Set objWord = appWord.Documents.Open("C:\MergeTemplate.doc") ' Make Word visible. appWord.Visible = True ' Set the mail merge data source as the database. Note the query parameter. objWord.MailMerge.OpenDataSource Name:="Database.mdb", LinkToSource:=True, Connection:="TABLE tblData", SQLStatement:="SELECT * FROM [tblData] WHERE [Orders.OrderID] = " & Forms!OrderForm!OrderID ' Execute the mail merge. objWord.MailMerge.Destination = wdSendToNewDocument objWord.MailMerge.Execute ' clean up and close Word, closing windows in reverse order that they were opened Set objWord = appWord.Documents("Form Letters1") objWord.Close wdDoNotSaveChanges Set objWord = appWord.Documents("Sampling Request Form - merge.doc") objWord.SaveAs ("C:\Output.doc") appWord.Quit Set appWord = Nothing End Function Good luck. Danny wrote: Is it possible to take the data from Access, and merge it into just one Word document? I wish to create a form letter addressed to one person, using the data that I have stored in an Access database. However, the only options I have discovered so far are to either create a mass-mailing, or to create a poorly formatted report in Access, then use the "publish it" function. This outputs again a poorly formatted document. Is it possible for me to design a form letter in Word, and have it pull the data for just one letter, rather than 100? |
#9
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Merging Access data into a Word document
You guys look like you know what you're talking about - slick tools. Maybe
you know this one too: In my Main Merge doc I have: fname fname In the Data doc I have column heading and two names fname Bill Mike When I merge, Bill, of course, replaces each fname with Bill and looks like this: Bill Bill What I want, is this: Bill Mike Is this possible? Any help is appreciated. " wrote: The solution depends on what level of automation that you need. In Word 2003, you can use Tools Letters/Mailings Mail Merge, and after selecting the Access table in step 3, check only the one recipient that you want. You may also try Albert Kallal's "MergeSingleWord". http://www.members.shaw.ca/AlbertKal.../msaccess.html I automated the process with Visual Basic code to merge the current record being displayed on an Access form. The form has fields to find and identify the desired record, a command button to launch this code, and a text box bound the data table primary key called OrderID. This article was used as a foundation: http://support.microsoft.com/?id=209976 The code requires reference (Tools References) to Word 11 Object Library; may need to browse for C:\PF\MS Office\Office11\msword.olb The Word template should not be bound to a data source. Bind it to a data source only to easily enter the merge fields, then convert it back to a normal Word document (Word 2000: Mail Merge Helper 1 Restore to normal Word document. Word 2003: Mail merge toolbar Main document setup Normal Word document). You may get errors from Word such as the "Data Link" window or complaints that Access is locked and needs an admin password. Post them to this thread. Here is the code. Any MVPs and pros, feel free to correct. Sorry for line wrapping; not sure why it does that. Function OutputDoc() Dim appWord As Word.Application Dim objWord As Word.Document Set appWord = New Word.Application Set objWord = appWord.Documents.Open("C:\MergeTemplate.doc") ' Make Word visible. appWord.Visible = True ' Set the mail merge data source as the database. Note the query parameter. objWord.MailMerge.OpenDataSource Name:="Database.mdb", LinkToSource:=True, Connection:="TABLE tblData", SQLStatement:="SELECT * FROM [tblData] WHERE [Orders.OrderID] = " & Forms!OrderForm!OrderID ' Execute the mail merge. objWord.MailMerge.Destination = wdSendToNewDocument objWord.MailMerge.Execute ' clean up and close Word, closing windows in reverse order that they were opened Set objWord = appWord.Documents("Form Letters1") objWord.Close wdDoNotSaveChanges Set objWord = appWord.Documents("Sampling Request Form - merge.doc") objWord.SaveAs ("C:\Output.doc") appWord.Quit Set appWord = Nothing End Function Good luck. Danny wrote: Is it possible to take the data from Access, and merge it into just one Word document? I wish to create a form letter addressed to one person, using the data that I have stored in an Access database. However, the only options I have discovered so far are to either create a mass-mailing, or to create a poorly formatted report in Access, then use the "publish it" function. This outputs again a poorly formatted document. Is it possible for me to design a form letter in Word, and have it pull the data for just one letter, rather than 100? |
#10
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Merging Access data into a Word document
See response to your latter post.
-- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Access101" wrote in message ... You guys look like you know what you're talking about - slick tools. Maybe you know this one too: In my Main Merge doc I have: fname fname In the Data doc I have column heading and two names fname Bill Mike When I merge, Bill, of course, replaces each fname with Bill and looks like this: Bill Bill What I want, is this: Bill Mike Is this possible? Any help is appreciated. " wrote: The solution depends on what level of automation that you need. In Word 2003, you can use Tools Letters/Mailings Mail Merge, and after selecting the Access table in step 3, check only the one recipient that you want. You may also try Albert Kallal's "MergeSingleWord". http://www.members.shaw.ca/AlbertKal.../msaccess.html I automated the process with Visual Basic code to merge the current record being displayed on an Access form. The form has fields to find and identify the desired record, a command button to launch this code, and a text box bound the data table primary key called OrderID. This article was used as a foundation: http://support.microsoft.com/?id=209976 The code requires reference (Tools References) to Word 11 Object Library; may need to browse for C:\PF\MS Office\Office11\msword.olb The Word template should not be bound to a data source. Bind it to a data source only to easily enter the merge fields, then convert it back to a normal Word document (Word 2000: Mail Merge Helper 1 Restore to normal Word document. Word 2003: Mail merge toolbar Main document setup Normal Word document). You may get errors from Word such as the "Data Link" window or complaints that Access is locked and needs an admin password. Post them to this thread. Here is the code. Any MVPs and pros, feel free to correct. Sorry for line wrapping; not sure why it does that. Function OutputDoc() Dim appWord As Word.Application Dim objWord As Word.Document Set appWord = New Word.Application Set objWord = appWord.Documents.Open("C:\MergeTemplate.doc") ' Make Word visible. appWord.Visible = True ' Set the mail merge data source as the database. Note the query parameter. objWord.MailMerge.OpenDataSource Name:="Database.mdb", LinkToSource:=True, Connection:="TABLE tblData", SQLStatement:="SELECT * FROM [tblData] WHERE [Orders.OrderID] = " & Forms!OrderForm!OrderID ' Execute the mail merge. objWord.MailMerge.Destination = wdSendToNewDocument objWord.MailMerge.Execute ' clean up and close Word, closing windows in reverse order that they were opened Set objWord = appWord.Documents("Form Letters1") objWord.Close wdDoNotSaveChanges Set objWord = appWord.Documents("Sampling Request Form - merge.doc") objWord.SaveAs ("C:\Output.doc") appWord.Quit Set appWord = Nothing End Function Good luck. Danny wrote: Is it possible to take the data from Access, and merge it into just one Word document? I wish to create a form letter addressed to one person, using the data that I have stored in an Access database. However, the only options I have discovered so far are to either create a mass-mailing, or to create a poorly formatted report in Access, then use the "publish it" function. This outputs again a poorly formatted document. Is it possible for me to design a form letter in Word, and have it pull the data for just one letter, rather than 100? |
#11
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Merging Access data into a Word document
Very complete suggestions. You've got me past my roadblock, and I'm much
appreciative. Thank you so much! " wrote: The solution depends on what level of automation that you need. In Word 2003, you can use Tools Letters/Mailings Mail Merge, and after selecting the Access table in step 3, check only the one recipient that you want. You may also try Albert Kallal's "MergeSingleWord". http://www.members.shaw.ca/AlbertKal.../msaccess.html I automated the process with Visual Basic code to merge the current record being displayed on an Access form. The form has fields to find and identify the desired record, a command button to launch this code, and a text box bound the data table primary key called OrderID. This article was used as a foundation: http://support.microsoft.com/?id=209976 The code requires reference (Tools References) to Word 11 Object Library; may need to browse for C:\PF\MS Office\Office11\msword.olb The Word template should not be bound to a data source. Bind it to a data source only to easily enter the merge fields, then convert it back to a normal Word document (Word 2000: Mail Merge Helper 1 Restore to normal Word document. Word 2003: Mail merge toolbar Main document setup Normal Word document). You may get errors from Word such as the "Data Link" window or complaints that Access is locked and needs an admin password. Post them to this thread. Here is the code. Any MVPs and pros, feel free to correct. Sorry for line wrapping; not sure why it does that. Function OutputDoc() Dim appWord As Word.Application Dim objWord As Word.Document Set appWord = New Word.Application Set objWord = appWord.Documents.Open("C:\MergeTemplate.doc") ' Make Word visible. appWord.Visible = True ' Set the mail merge data source as the database. Note the query parameter. objWord.MailMerge.OpenDataSource Name:="Database.mdb", LinkToSource:=True, Connection:="TABLE tblData", SQLStatement:="SELECT * FROM [tblData] WHERE [Orders.OrderID] = " & Forms!OrderForm!OrderID ' Execute the mail merge. objWord.MailMerge.Destination = wdSendToNewDocument objWord.MailMerge.Execute ' clean up and close Word, closing windows in reverse order that they were opened Set objWord = appWord.Documents("Form Letters1") objWord.Close wdDoNotSaveChanges Set objWord = appWord.Documents("Sampling Request Form - merge.doc") objWord.SaveAs ("C:\Output.doc") appWord.Quit Set appWord = Nothing End Function Good luck. Danny wrote: Is it possible to take the data from Access, and merge it into just one Word document? I wish to create a form letter addressed to one person, using the data that I have stored in an Access database. However, the only options I have discovered so far are to either create a mass-mailing, or to create a poorly formatted report in Access, then use the "publish it" function. This outputs again a poorly formatted document. Is it possible for me to design a form letter in Word, and have it pull the data for just one letter, rather than 100? |
#12
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Merging Access data into a Word document
Dear all, I have a similar problem with mail merge. I have a .doc document
and a data source from an oracle database which stores HTML data as text. The front end application has no problem recognizing the HTML tags and would display the HTML texts correctly. But once I tried to mail merge this HTML text to the Word document, Word would show the HTML tags as is. i.e. BRtest/BR instead of a line break before 'test', a & instead of &, and a Bbold/B instead of a bolded 'bold' text. I wonder if there's a way to make Word interpret the HTML tags automatically during the mail merge? Thanks in advance, Michael " wrote: The solution depends on what level of automation that you need. In Word 2003, you can use Tools Letters/Mailings Mail Merge, and after selecting the Access table in step 3, check only the one recipient that you want. You may also try Albert Kallal's "MergeSingleWord". http://www.members.shaw.ca/AlbertKal.../msaccess.html I automated the process with Visual Basic code to merge the current record being displayed on an Access form. The form has fields to find and identify the desired record, a command button to launch this code, and a text box bound the data table primary key called OrderID. This article was used as a foundation: http://support.microsoft.com/?id=209976 The code requires reference (Tools References) to Word 11 Object Library; may need to browse for C:\PF\MS Office\Office11\msword.olb The Word template should not be bound to a data source. Bind it to a data source only to easily enter the merge fields, then convert it back to a normal Word document (Word 2000: Mail Merge Helper 1 Restore to normal Word document. Word 2003: Mail merge toolbar Main document setup Normal Word document). You may get errors from Word such as the "Data Link" window or complaints that Access is locked and needs an admin password. Post them to this thread. Here is the code. Any MVPs and pros, feel free to correct. Sorry for line wrapping; not sure why it does that. Function OutputDoc() Dim appWord As Word.Application Dim objWord As Word.Document Set appWord = New Word.Application Set objWord = appWord.Documents.Open("C:\MergeTemplate.doc") ' Make Word visible. appWord.Visible = True ' Set the mail merge data source as the database. Note the query parameter. objWord.MailMerge.OpenDataSource Name:="Database.mdb", LinkToSource:=True, Connection:="TABLE tblData", SQLStatement:="SELECT * FROM [tblData] WHERE [Orders.OrderID] = " & Forms!OrderForm!OrderID ' Execute the mail merge. objWord.MailMerge.Destination = wdSendToNewDocument objWord.MailMerge.Execute ' clean up and close Word, closing windows in reverse order that they were opened Set objWord = appWord.Documents("Form Letters1") objWord.Close wdDoNotSaveChanges Set objWord = appWord.Documents("Sampling Request Form - merge.doc") objWord.SaveAs ("C:\Output.doc") appWord.Quit Set appWord = Nothing End Function Good luck. Danny wrote: Is it possible to take the data from Access, and merge it into just one Word document? I wish to create a form letter addressed to one person, using the data that I have stored in an Access database. However, the only options I have discovered so far are to either create a mass-mailing, or to create a poorly formatted report in Access, then use the "publish it" function. This outputs again a poorly formatted document. Is it possible for me to design a form letter in Word, and have it pull the data for just one letter, rather than 100? |
#13
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Merging Access data into a Word document
Michael - I have responsed (but not with the answer you seek) to your later
similar question. Peter Jamieson "Michael" wrote in message ... Dear all, I have a similar problem with mail merge. I have a .doc document and a data source from an oracle database which stores HTML data as text. The front end application has no problem recognizing the HTML tags and would display the HTML texts correctly. But once I tried to mail merge this HTML text to the Word document, Word would show the HTML tags as is. i.e. BRtest/BR instead of a line break before 'test', a & instead of &, and a Bbold/B instead of a bolded 'bold' text. I wonder if there's a way to make Word interpret the HTML tags automatically during the mail merge? Thanks in advance, Michael " wrote: The solution depends on what level of automation that you need. In Word 2003, you can use Tools Letters/Mailings Mail Merge, and after selecting the Access table in step 3, check only the one recipient that you want. You may also try Albert Kallal's "MergeSingleWord". http://www.members.shaw.ca/AlbertKal.../msaccess.html I automated the process with Visual Basic code to merge the current record being displayed on an Access form. The form has fields to find and identify the desired record, a command button to launch this code, and a text box bound the data table primary key called OrderID. This article was used as a foundation: http://support.microsoft.com/?id=209976 The code requires reference (Tools References) to Word 11 Object Library; may need to browse for C:\PF\MS Office\Office11\msword.olb The Word template should not be bound to a data source. Bind it to a data source only to easily enter the merge fields, then convert it back to a normal Word document (Word 2000: Mail Merge Helper 1 Restore to normal Word document. Word 2003: Mail merge toolbar Main document setup Normal Word document). You may get errors from Word such as the "Data Link" window or complaints that Access is locked and needs an admin password. Post them to this thread. Here is the code. Any MVPs and pros, feel free to correct. Sorry for line wrapping; not sure why it does that. Function OutputDoc() Dim appWord As Word.Application Dim objWord As Word.Document Set appWord = New Word.Application Set objWord = appWord.Documents.Open("C:\MergeTemplate.doc") ' Make Word visible. appWord.Visible = True ' Set the mail merge data source as the database. Note the query parameter. objWord.MailMerge.OpenDataSource Name:="Database.mdb", LinkToSource:=True, Connection:="TABLE tblData", SQLStatement:="SELECT * FROM [tblData] WHERE [Orders.OrderID] = " & Forms!OrderForm!OrderID ' Execute the mail merge. objWord.MailMerge.Destination = wdSendToNewDocument objWord.MailMerge.Execute ' clean up and close Word, closing windows in reverse order that they were opened Set objWord = appWord.Documents("Form Letters1") objWord.Close wdDoNotSaveChanges Set objWord = appWord.Documents("Sampling Request Form - merge.doc") objWord.SaveAs ("C:\Output.doc") appWord.Quit Set appWord = Nothing End Function Good luck. Danny wrote: Is it possible to take the data from Access, and merge it into just one Word document? I wish to create a form letter addressed to one person, using the data that I have stored in an Access database. However, the only options I have discovered so far are to either create a mass-mailing, or to create a poorly formatted report in Access, then use the "publish it" function. This outputs again a poorly formatted document. Is it possible for me to design a form letter in Word, and have it pull the data for just one letter, rather than 100? |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Word should catalog misspelled words to study. | Microsoft Word Help | |||
Word & WordPerfect | Microsoft Word Help | |||
How Come? | Mailmerge | |||
Word Document: merging a lot of info from Access | Mailmerge | |||
Specific Email Merge w/ Specific Attachements | Mailmerge |