+ Reply to Thread
Results 1 to 5 of 5

Need to close Text file after copying it's contents via Excel 2000 VBA

  1. #1
    Forum Contributor
    Join Date
    06-11-2018
    Location
    Lebanon, NH
    MS-Off Ver
    2000 and 2010
    Posts
    106

    Need to close Text file after copying it's contents via Excel 2000 VBA

    Good afternoon!
    I am cleaning up a couple issues that might cause issues for someone else using the Workbook. The macro does everything I need it to do except to close the text file after copying the contents. Text file is generated by the AS400 and the name of the text file is variable, thus the wildcard in the file name. I need to modify the macro to close the text file when it is done with it. I'm running into issues.

    I've tried Windows("S:\Estimator\QPQUPRFIL_GJH_QDFTJOBD*.txt").Activate
    Windows.Close

    I've tried some modifications of this with no luck at all.
    Not sure if my issue is the wild card or if it is syntax or something else./
    Any suggestions will be very much appreciated.
    Thanks,
    Bill


    Please Login or Register  to view this content.

  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: Need to close Text file after copying it's contents via Excel 2000 VBA

    Hello billfinnjr,

    After looking at the code, I am not really sure what your issue is because there is no open text file, only a new workbook that contains the text file contents.

    If you want to close this workbook without saving it then you could use this...
    Please Login or Register  to view this content.
    This will close the most recently opened workbook, which will be the one with the text file contents.
    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
    Forum Contributor
    Join Date
    06-11-2018
    Location
    Lebanon, NH
    MS-Off Ver
    2000 and 2010
    Posts
    106

    Re: Need to close Text file after copying it's contents via Excel 2000 VBA

    Leith Ross,
    Thanks for your response but the Text file is opened to copy the data and never closes unless I physically close it. I would love to be able to close it in the Macro so as to prevent oversights.
    Thanks much
    Bill

  4. #4
    Forum Contributor
    Join Date
    06-11-2018
    Location
    Lebanon, NH
    MS-Off Ver
    2000 and 2010
    Posts
    106

    Re: Need to close Text file after copying it's contents via Excel 2000 VBA

    After some research and head scratching I figured this out. Right after I open the text file I added this line;
    Please Login or Register  to view this content.
    At the end of the macro I added this line;
    Please Login or Register  to view this content.
    Problem is resolved and the unknowing won't have to worry about closing the text file manually
    Learned something new in the bargain!
    Thanks,
    Bill

  5. #5
    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: Need to close Text file after copying it's contents via Excel 2000 VBA

    Hello billfinnjr,

    Is this text file open on your desktop?

    Okay my system is a little slow. You got it figured out. Good job!
    Last edited by Leith Ross; 12-11-2018 at 12:14 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 03-23-2018, 03:52 PM
  2. Garble Text when i open Excel 2000 file
    By computerdynamo in forum Excel General
    Replies: 2
    Last Post: 06-26-2010, 10:37 AM
  3. looping, Open text file, copy text, close text file
    By jwilds1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-18-2009, 05:12 PM
  4. Replies: 1
    Last Post: 07-22-2006, 01:33 PM
  5. How do I close a link in Excel 2000?
    By SundanceKidLudwig in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-05-2005, 10:05 AM
  6. [SOLVED] missing close box in excel 2000
    By dmtech in forum Excel General
    Replies: 0
    Last Post: 09-22-2005, 10:05 AM
  7. [SOLVED] Hyperlink in Excel 2000 can't open bookmarked Word 2000 file
    By DCheslock in forum Excel General
    Replies: 1
    Last Post: 05-05-2005, 06:06 PM

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