+ Reply to Thread
Results 1 to 7 of 7

Opening a text file through a macro

  1. #1
    Registered User
    Join Date
    02-23-2012
    Location
    Loveland, CO
    MS-Off Ver
    Excel 2007
    Posts
    3

    Opening a text file through a macro

    Hello,

    I could use some assistance with text files created from a macro. What I am trying to do is open a text file, populate it with information, and then I would like the text file to stay open so the user can save where appropriate. I currently am able to open a saved blank text file by using...
    Please Login or Register  to view this content.
    I am then able to write the information to it that I want using TxtFile.writeline (TxtData). This method works for creating the document that I need but then it resaves over the previous file and closes. The closing confuses me because I do not call for it to close.

    What I would prefer to happen is for a "new" text file to open, write the lines of text, and then remain open.

    Thanks in advance, Abe.
    Last edited by Leith Ross; 02-23-2012 at 10:34 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Opening a text file through a macro

    Hello aweagraff ,

    Welcome to the Forum!

    If you need to open a new text file, here is an easier way.
    Please Login or Register  to view this content.
    This will open Notepad. The user can then type in the information or paste it in where needed.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    12-15-2003
    Posts
    9

    Re: Opening a text file through a macro

    Can you pls post your full code - I can't see why the text file would close without instruction to do so

    And rather than append to a blank saved file why not just create a new one?

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-23-2012
    Location
    Loveland, CO
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Opening a text file through a macro

    Thanks for the information, below is my code. I do like the idea of creating a new file and have updated as such. The text file is still closing on me after writing the information and I do not see anything in the code that would .
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 03-05-2012 at 06:48 PM. Reason: Added Code Tags

  5. #5
    Registered User
    Join Date
    02-23-2012
    Location
    Loveland, CO
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Opening a text file through a macro

    Please Login or Register  to view this content.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Opening a text file through a macro

    Hello

    Since you want to use the FSO, you will need to learn more about what it does and how it works. I found a good site that details the FSO. Click the link below.

    The File System Object

  7. #7
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    951

    Re: Opening a text file through a macro

    Try:
    Please Login or Register  to view this content.
    Last edited by lilsnoop; 03-05-2012 at 08:31 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1