+ Reply to Thread
Results 1 to 9 of 9

Search for string of text only within "*.log" files in the folder

  1. #1
    Registered User
    Join Date
    08-08-2013
    Location
    Edinburgh
    MS-Off Ver
    Excel 2007
    Posts
    11

    Search for string of text only within "*.log" files in the folder

    Hi

    I have a VBA function which searches inside all the files in a folder for the specific text and extract the value in the excel spreadsheet.
    There are 3,000 files in the folder only 1,500 of them are "*.log", which are of interest to search within.

    I am using the code below to search within each file:

    Please Login or Register  to view this content.
    Can it be possible to filter files to search only "*.log" files, and then start searching for matching text?

    Thanks
    Harkirat

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Search for string of text only within "*.log" files in the folder

    Please Login or Register  to view this content.
    you might need to change opentextfile(filname,1) to include the folderpath.

  3. #3
    Registered User
    Join Date
    08-08-2013
    Location
    Edinburgh
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Search for string of text only within "*.log" files in the folder

    Quote Originally Posted by yudlugar View Post
    Please Login or Register  to view this content.
    you might need to change opentextfile(filname,1) to include the folderpath.

    Thanks a lot Yudlugar for your reply

    I am getting compile error "argument not optional" at .READ in

    Please Login or Register  to view this content.
    Can you help again please

    Thanks
    Harkirat

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Search for string of text only within "*.log" files in the folder

    Have you tried:
    Please Login or Register  to view this content.
    ?

  5. #5
    Registered User
    Join Date
    08-08-2013
    Location
    Edinburgh
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Search for string of text only within "*.log" files in the folder

    I tried just now, giving same compile error.
    I then tried:
    Debug.Print filname

    no output?

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Search for string of text only within "*.log" files in the folder

    Ok,

    I've built some dummy files and tested this one and seems to work:
    Please Login or Register  to view this content.
    note - you need to change E:\ to your folder path.

  7. #7
    Registered User
    Join Date
    08-08-2013
    Location
    Edinburgh
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Search for string of text only within "*.log" files in the folder

    Thanks a lot for your effort and patience.

    1) Your code works fine with hardcoded Dir filename, but it does not loop through all the LOG files, only reads first file
    Please Login or Register  to view this content.
    whenever I use variable in dir function, it does not work
    Please Login or Register  to view this content.

    2) Why am I not getting any output with: (filename retuned by DIR() is a text string)
    Please Login or Register  to view this content.

    3) Why am I not able to do this (invalid procedure call) however, it is a TextStream Object..?

    Please Login or Register  to view this content.
    because I later need a text string to SPLIT
    Please Login or Register  to view this content.

    ****************************************
    Below is the code I am using:

    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Search for string of text only within "*.log" files in the folder

    Hi,

    1. When you use the variable in your code, the variable is set to
    Please Login or Register  to view this content.
    so your dir command is looking for files title "New Folder*.log" in the root of C, you need to use:
    Please Login or Register  to view this content.
    [/CODE]
    2. No idea, what do you mean by output?
    3. I think maybe you need:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-08-2013
    Location
    Edinburgh
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Search for string of text only within "*.log" files in the folder

    Thanks a ton Yudlugar.

    Please Login or Register  to view this content.
    did the magic

    and I was just being mysef: SILLY
    I didn't do:
    Please Login or Register  to view this content.
    Thanks

+ 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. [SOLVED] Search numbers in a text string, find largest "value" return a value
    By OilGasKing in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-27-2013, 09:01 PM
  2. Replies: 10
    Last Post: 06-04-2012, 09:38 PM
  3. search directory for excel-files and put A136 from tab "1"-"20" in a table
    By Wim_VDW in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-30-2012, 10:33 AM
  4. Replies: 14
    Last Post: 06-27-2008, 08:14 PM
  5. "Folder Select" Dialogue - Opening multiple files from selected folder
    By Rob in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-30-2005, 10:05 AM

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