Results 1 to 4 of 4

Thread: MS Word

  1. #1

    Thread Starter
    Hyperactive Member razzaj's Avatar
    Join Date
    Oct 1999
    Location
    jounieh
    Posts
    261

    MS Word

    Once one has referenced the Word 9.0 Library in VB.

    How Can I create a new document (blank to start with)

    and how can I "write" to it without having word open.

    I can do this in excel but i cant seem to find any "New" function in the Word library ...

    Some sample code would be of great help.

    - Thanks.
    - regards -
    - razzaj -

  2. #2
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    St. Albans, Herts, UK
    Posts
    259
    As with all Office Apps, the easiest way to automate them is to record a Macro in the App, and copy the VB code generated into your project, with minor modifications
    VB Code:
    1. Dim MyWord As New Word.Application
    2.  
    3. MyWord.Visible = False
    4. MyWord.Documents.Add
    5. MyWord.Activate
    6. MyWord.Selection.InsertAfter "New Text Here"
    Remeber if you keep it with .Visible =False, to quit with
    MyWord.Quit wdDoNotSaveChanges
    This will prevent an invisible dialog box coming up asking if you want to save changes. (Except of course you can't see it...)
    Last edited by gab2001uk; Dec 2nd, 2001 at 05:52 PM.
    Graham, www.gab2001uk.com VBExplorer Forum Moderator VBExplorer
    www.gab2001uk.com For comparing and contrasting DAO with ADO
    Code for Creating, Copying, Compacting, Replicating, Synchronising Access 97/2000 databases plus showing Schemas and using .Seek

  3. #3

    Thread Starter
    Hyperactive Member razzaj's Avatar
    Join Date
    Oct 1999
    Location
    jounieh
    Posts
    261
    Thanks that helped.

    I have another question Though.

    How can I Save the content of a word file (with aall the formating)

    into aa database for example. to be able to restore it later .

    I am not sure this is doable. but it would help a lot.

    thanks again.
    - regards -
    - razzaj -

  4. #4
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    -= a peet post =-

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