Results 1 to 3 of 3

Thread: Assign a string to Word object to print

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254
    Hi,
    can anyone let me know how to print a string using the word application object model.

    I think it should be simple but don't know the correct objects to use. Put simply I have a string which I want to print from VB, via MS word without showing the word application.

    Thanks in advance.

    Lenin

  2. #2
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195
    First of all, add a reference to you project for the Microsoft Word 8.0 Object library. Then this will work:


    Dim WordApp As Word.Application

    'Starting Word
    Set WordApp = New Word.Application
    WordApp.Application.Visible = False
    WordApp.Documents.Add
    WordApp.ActiveDocument.Words(1).InsertAfter "New text "
    WordApp.ActiveDocument.PrintOut Background:= False
    WordApp.Documents.Close wdDoNotSaveChanges
    WordApp.Application.Quit
    Set WordApp = Nothing

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254
    HDR,
    many thanks, that is exactly what I required.

    Lenin

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