Results 1 to 8 of 8

Thread: Merge One table into document

  1. #1

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  3. #3

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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?

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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.

    Quote 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  5. #5

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Merge One table into document

    Here is a very quick example of a MM baced on an existing MM template document.
    VB Code:
    1. Option Explicit
    2. 'Add reference to MS Word xx.0 Object Library
    3. Private moApp As Word.Application
    4.  
    5. Private Sub Command1_Click()
    6.     Dim oDoc As Word.Document
    7.     moApp.Visible = True
    8.     Set oDoc = moApp.Documents.Add("D:\Test.dot", , , True)
    9.     With oDoc.MailMerge
    10.         .MainDocumentType = wdFormLetters
    11.         .OpenDataSource Name:="D:\RobDog888.mdb", LinkToSource:=True, Connection:="TABLE ClientData"
    12.     End With
    13.     With oDoc.MailMerge.DataSource
    14.         .FirstRecord = 1
    15.         .LastRecord = 20
    16.     End With
    17.     With oDoc.MailMerge
    18.         .Destination = wdSendToPrinter 'wdSendToNewDocument; wdSendToFax; wdSendToEmail
    19.         .Execute True
    20.     End With
    21.  
    22. End Sub
    23.  
    24. Private Sub Form_Load()
    25.     Set moApp = New Word.Application
    26. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  7. #7

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Merge One table into document

    Congrats on the Double-Greens. And thanks for the code.

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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
  •  



Click Here to Expand Forum to Full Width