Results 1 to 5 of 5

Thread: Create and SHOW new text document

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Location
    U.S.
    Posts
    23

    Create and SHOW new text document

    I know this is a stupid question but I can't figure out how to do it. I have an application that allows the user to look at a text box with results from a query in it.

    I want to give the user the ability to create a text document with the info in it. I have searched the forum and can't find an answer.

    I want to know how to create the document, add the info AND THEN SHOW IT SO THE USER WILL THEN SEE IT IMMEDIATELY.

    Please help.

  2. #2
    Frenzied Member Mega_Man's Avatar
    Join Date
    Mar 2001
    Location
    North of England, South-East of Iceland
    Posts
    1,067
    Add a reference to the Microsoft Word 8 object library
    and then add the following
    VB Code:
    1. Dim app As Word.Application
    2. Set app = CreateObject("Word.Application")
    3. app.Visible = True
    4. app.Documents.Add
    5. app.Selection.TypeText Text1.Text ' Your text box info

    Mega.
    "If at first you don't succeed, then skydiving is not for you"

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Location
    U.S.
    Posts
    23
    Thanks mega,

    I am familar with creating a word doc. though. I am trying to create a txt file so that it will work on any system. I can create the file but I want the user to see it immediately.

    Any ideas?

  4. #4
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    Try,

    VB Code:
    1. Shell "Notepad.exe  filename", vbNormal

  5. #5
    Frenzied Member Mega_Man's Avatar
    Join Date
    Mar 2001
    Location
    North of England, South-East of Iceland
    Posts
    1,067
    VB Code:
    1. Open "c:\textfile.txt" For Output As #1
    2. Write #1, Text1.Text ' Your text box
    3. Close #1
    4. Shell "Notepad.exe  c:\textfile.txt", vbNormal
    This is a very quick way. I would personally use the FileSystemObject to do it properly but this will achieve what you want.

    Mega.
    Last edited by Mega_Man; Jan 11th, 2002 at 03:31 PM.
    "If at first you don't succeed, then skydiving is not for you"

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