Results 1 to 4 of 4

Thread: Print Text and Variables in a Word doc/dot

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    Okay I open the Word doc actually dot that I need. Now I need to with code print text with variables in between; any ideas?

    Should I use a bookmark; start at the beginning of the doc and have the code print the info? But how would the code in VB look to do this; any examples would be great!

    Thanks

  2. #2
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195
    I think this is what you are looking for:

    Dim WordApp As Word.Application

    'Starting Word
    Set WordApp = New Word.Application
    DoEvents
    'Open template
    WordApp.Documents.Open "Template path and name.dot"
    If Err = 0 Then
    'Attaching data source
    WordApp.ActiveDocument.MailMerge.OpenDataSource "Data path and name"
    If Err = 0 Then
    'Run the mail merge
    WordApp.ActiveDocument.MailMerge.Execute
    'Save the document
    If Err = 0 Then
    WordApp.ActiveDocument.SaveAs "Save path and filename.doc", wdFormatDocument
    If Err = 0 Then
    'Close all open Word documents and exit Word
    WordApp.Documents.Close wdDoNotSaveChanges
    WordApp.Application.Quit
    Set WordApp = Nothing

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    I dont need to do a word merge, I would just like to insert default text into the document that is stringed to variables from the program. The merge would be slower and more complicated for what I need.

    Thanks

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241

    here is the magical code once i open the active document i do this code to insert variables and text!!!

    obj.Selection.TypeText Date ' Insert current date

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