|
-
Feb 10th, 2005, 07:05 PM
#1
Merge One table into document
I have set up my query to find the merge data to use, and also have included the fields that I need to send it out. The fields are not going to change.
How do I let them fire up word, and then select whether to print,fax, or email the letters? I suppose it wouldn't be that hard to print or fax, but email is tougher.
How could I let WORD do the work for me? And just let the user navigate through the mailmerge screen? It seems to me that I should be able to use the one table in place of two, but I don't know how.
Is that what you meant by pre-populating the table?
Thanks.
-
Feb 10th, 2005, 07:19 PM
#2
Re: Merge One table into document
Sorry about not getting an ex. for you last night. I was busy working on a project for work.
You are setting up the rs in Word's VBA?
If I usderstand your data layout then you have say 20 clients that need a
dataset of x number of records that pertain to each client?
You can allow the user to choose which method they want to do by
automating the commandbars of Word. With this you can use
the .ShowEnvelope method to view the To:, CC:, Subject:, etc.
So you can let Word do it all.
I really dont like MM's, btw.
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 10th, 2005, 07:29 PM
#3
Re: Merge One table into document
I created the rs in VB. I haven't started with Word yet. Wouldn't it be better to do things from the program? I also have a section that sets up labels. I click the labels button, and it opens the document that already merges the addresses into the label page and the user just clicks "Print".
I don't know if I should do the same thing for the letters, or automate them both, so that the labels get printed automatically?
Do the letters require Word or can I do that from VB as well?
- Also, how should I get the fields onto the form letter? Does it require bookmarks to replace the data? I found an example of that yesterday to do it from VB. Can you have multiple letters print from one rs? How?
-
Feb 10th, 2005, 07:33 PM
#4
Re: Merge One table into document
Create a Word document setup the way you need it. Then save it as a template (.dot) file.
Then you can access the template using WOM.
You can have different templates for each type of MM or try to change it
dynamically in the document.
 Originally Posted by dglienna
Do the letters require Word or can I do that from VB as well?
How do you mean?
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 10th, 2005, 07:52 PM
#5
Re: Merge One table into document
Allright. I think I have a handle on this, finally. I create a mailmerge using the wizard, and it writes the sql automatically, which gets saved as a dot template. When I open the dot template, it loads all of the records, and prints them all at once also. I'd me interested in using VB to do some of this. Do you think you could whip up some kind of example to base off of?
Last edited by dglienna; Feb 10th, 2005 at 09:14 PM.
-
Feb 10th, 2005, 09:46 PM
#6
Re: Merge One table into document
Here is a very quick example of a MM baced on an existing MM template document.
VB Code:
Option Explicit
'Add reference to MS Word xx.0 Object Library
Private moApp As Word.Application
Private Sub Command1_Click()
Dim oDoc As Word.Document
moApp.Visible = True
Set oDoc = moApp.Documents.Add("D:\Test.dot", , , True)
With oDoc.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource Name:="D:\RobDog888.mdb", LinkToSource:=True, Connection:="TABLE ClientData"
End With
With oDoc.MailMerge.DataSource
.FirstRecord = 1
.LastRecord = 20
End With
With oDoc.MailMerge
.Destination = wdSendToPrinter 'wdSendToNewDocument; wdSendToFax; wdSendToEmail
.Execute True
End With
End Sub
Private Sub Form_Load()
Set moApp = New Word.Application
End Sub
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 10th, 2005, 10:09 PM
#7
Re: Merge One table into document
Congrats on the Double-Greens. And thanks for the code.
-
Feb 10th, 2005, 10:24 PM
#8
Re: Merge One table into document
No prob. and Thanks.
The code is just to get you started because I dont have allot of time tonight
to something more detailed. But you can see that to email or print or ?? is
quite easier than you thought, huh 
If you have more Q's let me know because I am not sure how exactly you
need it to work.
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 
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
|