+ Reply to Thread
Results 1 to 6 of 6

How do I check text file is blank or not

  1. #1
    Forum Contributor
    Join Date
    10-01-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    125

    How do I check text file is blank or not

    Hi I have one text file which is with no data. I mean it is blank. I would like to use one if command if text file is blank. For example as below:

    Please Login or Register  to view this content.
    Can any body help me?
    Last edited by krish T; 11-14-2010 at 11:49 AM. Reason: solved

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: How do I check text file is blank or not

    Did you consider checking the properties of a file ?



  3. #3
    Forum Contributor
    Join Date
    10-01-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    125

    Re: How do I check text file is blank or not

    No.I don't have idea. Here I am looking for the following if it is possible:

    step1: Check the text file.
    step2: if it is blank, gives message that it is blank
    step3: if it is not blank, it has to display the data

    Please let me know if you need any other information.

    Thanks

  4. #4
    Forum Contributor
    Join Date
    10-01-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    125

    Re: How do I check text file is blank or not

    I have tried some thing as below: Please correct If it is wrong.
    Please Login or Register  to view this content.
    Here I am able to see the contents if text file is not blank and able to get the message as "The file is empty" if it is blank.
    But not able to see all the contents if text file is big. How can I see all contents of text file?
    Last edited by krish T; 11-13-2010 at 12:32 PM. Reason: modification

  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: How do I check text file is blank or not

    Hello krish,

    This macro should help. If the file isn't 0 bytes then the text file will be displayed in NotePad. Once NotePad is closed, the macro will resume. If there is no data, the message dialog is displayed.
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 11-13-2010 at 02:26 PM. Reason: Removed unused variable
    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!)

  6. #6
    Forum Contributor
    Join Date
    10-01-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    125

    Re: How do I check text file is blank or not

    Hi Leith Ross, That is what exactly I am looking for. Thanks a lot. Really helpful.

    -krish

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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