-
Feb 8th, 2005, 05:46 PM
#1
Merge two tables into one document?
I have two tables. One is a list of clients, and one is a list of data to be sent to all clients. I want to use Word to mailmerge the two together, except that there doesn't seem to be a way to do it!
Any ideas on the best way to go about this? Should I create a multipage document, and then send that via mailmerge? (Can I build the mailmerge document dynamically?)
I already have labels for the clients, so maybe I could generate the mailmerge with the data, and then dynamically add merge fields for the clients?
I hope that I don't have to use VB to do all the merges, but that's the way I see that it can be done.
Thanks for the help!
-
Feb 8th, 2005, 06:12 PM
#2
Re: Merge two tables into one document?
David, you can do it from either Access or Word, assuming that the two tables
are in Access. From Access, you create a query that will give you the resulting
recordset you want in Access. Then you can go File > Export... and select
Save As Type box, click Microsoft Word Merge (*.txt). Then click the arrow
to the right of the Save In box, and select the drive or folder to export to. In
the File Name box, enter the file name, and then click Export.
Access creates the data source containing the field names and all the data from your table.
Also, in a word mail merge data source, the first record in the file contains
the field names and is called the header row. All succeeding records are the
data rows. The field names in the header record must match the field names
in the main document. If they don't match, edit the field names either in the
data source (you can open the data source in Microsoft Word) or in the main
document so they do match.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Feb 8th, 2005, 07:33 PM
#3
Re: Merge two tables into one document?
I was trying not to have to use Access, as I am loading tables in VB and making temporary tables. I'd like to just kind of automate Word to make it as seamless as possible. Could I do a SQL statment to make the temporary table from within VB? I'm not sure that users will have Access.
The other problem that I had was dynamically changing the merge document in word. It seems to open the same table each time, but I need to set it the first time if I package the app. It works fine on my machine, but I need it to work when installed elsewhere.
Thanks for your help!
-
Feb 8th, 2005, 07:39 PM
#4
Re: Merge two tables into one document?
I'm just getting ready to leave, but you can create an ADO recordset with the resultset you need and
set that as the recordsource for the mailmerge in Word. You need to do a little automation of word so it knows your
passing a prepopulated recordset for the MM.
Be back tonight with more explaination/help.
Yea, time to go home!
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Feb 8th, 2005, 08:23 PM
#5
Re: Merge two tables into one document?
I'd like to hear more about it.
Last edited by dglienna; Feb 9th, 2005 at 01:38 AM.
-
Feb 9th, 2005, 06:06 PM
#6
Re: Merge two tables into one document?
-
Feb 9th, 2005, 06:15 PM
#7
Re: Merge two tables into one document?
A little, I'm debuggin my vb.net usercontrol .
When you say that the fields are going to be changing, do you mean the number of fields, location, or names ?
That part will make it difficult.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Feb 9th, 2005, 06:56 PM
#8
Re: Merge two tables into one document?
writing a query to include the fields that are sent out to the selected merge documents. Would it be better to have the same fields sent out each time?
I wanted to be able to choose number of fields each time.
If you could get me started, I'll work out the details. I'm not sure if I just make 15 records of each, and merge each with 15 people, or set up the merge document "populated" as you say that will send each record to the 15 person in the list.
-
Feb 9th, 2005, 07:32 PM
#9
Re: Merge two tables into one document?
Its almost time to go home so if we can figure out which way we will go with this I will try to whip up something tonight.
I think you may be able to do it using the MM in Word as is (depending on your data and how you need it).
You can create a query in Access that will contain a one to many relationship between your clients and data
tables. In Word you can assign the fields for the receipient separately from the other fields in the document.
I'm not sure if this is how you need it, but it will give you something to look into in the mean time.
Later.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Feb 9th, 2005, 08:05 PM
#10
Re: Merge two tables into one document?
I want to use SQL, not access. Don't want to requre that users have Access installed. Thanks in advance for you help. Have to spread the wealth, but I will do that tonight.
Or do you mean to create the tables and relationships in Access? Willl I have any trouble writing to them with SQL?
Last edited by dglienna; Feb 10th, 2005 at 01:54 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|