VB.NET / DataSet / Merge

Discussion in 'OT Technology' started by ibjhb, Feb 15, 2005.

  1. ibjhb

    ibjhb the original ib

    Joined:
    Feb 9, 2005
    Messages:
    6,114
    Likes Received:
    0
    Location:
    St. Petersburg, FL
    I’m looking for any software, or a general idea how to, that, in VB.NET, you could take a dataset, have VB open a pre-made word doc (a form letter of sort) and use VB to insert merge fields based on the dataset and then merge it out to a new document or to a printer.

    Any ideas?
     
  2. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    I've found it easier in the past to do this from Word (mail merger) than from Access or VB.net, unless it's not a one time thing.
     
  3. ibjhb

    ibjhb the original ib

    Joined:
    Feb 9, 2005
    Messages:
    6,114
    Likes Received:
    0
    Location:
    St. Petersburg, FL
    It's not a one time thing. I know how to do it if I prepare the documents...

    I'm developing an application that would let clients design their own word documents. They would be able to type it up and then use my program to insert the merge fields and then merge it out...
     
  4. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    Sounds like you need to control Word from VB which is entirely possible. For example:

    Sub OpenWordDoc(strDocName As String)
    Dim objApp As Object

    'Opens the document

    Set objApp = CreateObject("Word.Application")
    objApp.Visible = True
    objApp.Documents.Open strDocName
    End Sub

    Would open up a document strdocname. You just need to find out the other vb commands word uses to fill in the data. If they are customizing the template, then you need to be very careful on how they name the fields you want filled in - they're going to have to match your dataset.
     
  5. ibjhb

    ibjhb the original ib

    Joined:
    Feb 9, 2005
    Messages:
    6,114
    Likes Received:
    0
    Location:
    St. Petersburg, FL
    Getting closer.

    I know how to control Word via VB. I do it all the time to merge out documents that are pre-made. I make "forms" all the time, but I set the MergeFields beforehand.

    I need to be able to have a way that once the document is open via VB, I use VB and let people add the MergeFields themselves (drag-and-drop would be nice). Then VB could save the document for future use and then merge the document out for the user.

    I'm just not sure on the adding MergeFields part...
     

Share This Page