Results 1 to 5 of 5

Thread: Maybe a silly question => how to write data to a word doc

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Location
    The Netherlands
    Posts
    26

    Post

    it's all in the subject above...

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Post

    spandex44: Nope - if DOC files were normal text files, how could you get the formatting? The files are in binary format.

    This is how to (for example) copy Text1.Text to C:\Text1.Txt...
    Code:
    Dim nFile As Byte
    If Len(Dir("C:\Text1.Txt")) <> 0 Then
        If MsgBox("The file already exists! Would you like to overwrite it?", vbQuestion or vbYesNo, "File Exists") = vbNo Then
            Exit Sub ' Exit Function, Exit Property, Exit Room, Exit World, Exit Whatever
        End If
    End If
    nFile = FreeFile
    Open "C:\Text1.Txt" For Output As #nFile
        Print #nFile, Text1.Text
    Close #nFile
    ------------------
    Yonatan
    Teenage Programmer
    E-Mail: [email protected]
    ICQ: 19552879
    AIM: RYoni69

  3. #3
    Hyperactive Member Juan Carlos Rey's Avatar
    Join Date
    Aug 1999
    Location
    Mendoza, Argentina
    Posts
    301

    Post

    Take a look at this post:

    http://www.vb-world.net/ubb/Forum1/HTML/007402.html

    You'll have to pre-format your Word Doc the way you want it to look, with fonts, spaces, etc., even tables. Name each field as "Position1", "Position2", etc.

    In your VB app you'll have any number of text boxes, option boxes, whatever you like.
    Then you insert all this stuff into Word, which works in back-ground, and each field will go neatly into the corresponding position. Then you can either print or save your Word Document.

    If you need more help, re-post here.
    Regards, JuanCar


    [This message has been edited by Juan Carlos Rey (edited 11-21-1999).]

  4. #4
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Post

    Maybe a silly answer: Use Microsoft Word... Sorry, impossible otherwise (without getting sued???).

    ------------------
    Yonatan
    Teenage Programmer
    E-Mail: [email protected]
    ICQ: 19552879
    AIM: RYoni69

  5. #5
    Guest

    Post

    I think the best way(in my opinion) to deal with files like .xls, .doc is to use their native applications as OLE servers and manipulate the content using the Applications native methods. The only drawback is that you must have the application installed on your system and make sure you have the correct version.
    Look these up:
    1. Word help files under OLE
    2. Vb help files under CreateObject()


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