+ Reply to Thread
Results 1 to 11 of 11

"application.FileSearch" Excel 2007 update

  1. #1
    Registered User
    Join Date
    07-02-2009
    Location
    Cannock, England
    MS-Off Ver
    Excel 2007
    Posts
    13

    "application.FileSearch" Excel 2007 update

    Hi everyone!

    I have a piece of code that was written by someone else (namely Phil_V, from these very forums) that only works in versions of Excel before 2007. I was just hoping that someone could update the code for me?

    I know it's a lot to ask, but I simply don't have the expertise to do it myself I really appreciate any help received.

    The code that needs updating is as follows:

    Please Login or Register  to view this content.
    Last edited by danrayson; 07-07-2009 at 08:19 AM. Reason: edit tags

  2. #2
    Registered User
    Join Date
    07-03-2008
    Location
    Hyderabad, India
    MS-Off Ver
    2003 and 2007
    Posts
    58

    Re: "application.FileSearch" Excel 2007 update

    Hi,

    Application.FileSearch is not in Excel 2007.

    Try to use FileScripting instead of FileSearch Method.

    eg,
    Please Login or Register  to view this content.
    Salim

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: "application.FileSearch" Excel 2007 update

    Did you state the Excel version in your original question? This is why it is important to do so. There is no Application.Filesearch in Excel 2007.

    http://excel2007tips.blogspot.com/
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: "application.FileSearch" Excel 2007 update

    I don't think it was mentioned originally in the Q that Dan was using 2007, but he does have it filled in in his profie, (top right of his posts), and I just didn't notice it until I'd already written the code.
    I'll have a look at correcting the code using File Scripting instead Dan, but it will be likely Sunday before I get a chance now

    Phil
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: "application.FileSearch" Excel 2007 update

    The link contains alternative code, that I believe will be backwards compatible.

  6. #6
    Registered User
    Join Date
    07-02-2009
    Location
    Cannock, England
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: "application.FileSearch" Excel 2007 update

    I'm sorry about not making it clear I was working in a later version of Excel, I just assumed it was already known :-/ Bit stupid of me tbf.

    I'm going to try and play with the code that Salimudheen suggested, although I only have the faintest clue of where to start. I'm completely new to coding. I will keep this post updated with any progress I can make by myself.

    On the other hand, Phil, I would be very grateful if you could update it for me, as I from what I've seen you're a coding king of some kind. Rest assured, what goes around comes around. *It's a surprise*.

  7. #7
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Post Re: "application.FileSearch" Excel 2007 update

    Ok, so working from Roy's link and a few other sources dotted around the net I have rewritten a section of the code. I have written my own 'FileSearch' function that should work under Excel 2007 to replace the Application.FileSearch, (code below). It doesn't have all the functionality, in that it won't (currently) search subfolders, but you don't need it to for what you require.

    I have also made a few other changes to the code that were neccasary to allow this new function to fit in.

    Revised workbook (from based from the original thread) attached, FileSearch code below, (already in the workbook):

    Please Login or Register  to view this content.
    As usual, any questions or problems please do ask

    Oh, and if it works let me know that too please
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    07-02-2009
    Location
    Cannock, England
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: "application.FileSearch" Excel 2007 update

    Oh...my...gosh...

    IT WORKED!

    There was a moment when Excel was running through the macro that I thought it was going to play that "you-just-failed" sound, but it updated the cells perfectly.

    Excellent work there Phil! You just achieved God status in Blackened Skies (My in game corp name.) And you have my gratitude.

    I will be PMing you either tomorrow or on Monday regarding that reward I was talking about. (I hope you have a PayPal account.)

  9. #9
    Registered User
    Join Date
    07-02-2009
    Location
    Cannock, England
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: "application.FileSearch" Excel 2007 update

    I've found a problem with the naming of the items in the "Item" column. The "Datacore" type items have a naming structure that for some reason makes the code cut off half the name.

    They're named "Datacore - datacoreType", but the Item column only shows "Datacore" for every type. This pretty much makes the list useless, as I don't know which is which

    Having a column with the itemID would give me a workaround, and would also most likely be easier to accomplish than getting the whole names to appear, I'm not sure. However, having the full names would be preferred.

    I've attached a .zip with some Datacore market exports for you to test with, along with some other exports mixed in.

    I hope you can find the time/energy to help me out some more, as always, whatever you can do, Phil, will be greatly appreciated.

    Thanks in advance,
    Dan.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Post Re: "application.FileSearch" Excel 2007 update

    Hi Dan,

    Firstly please let me say that rewards are not neccasary. I do not do this is search of rewards, but to help other people and hopefully give back something to the community that I have used to learn my VBA knowledge from

    Now onto the job at hand

    The reason the datacore objects were having an issue was because of how I processed the strings.
    A standard file name was like this:
    Please Login or Register  to view this content.
    So I used the '-' as delimiters, taking the 'location' to be all the text up to the first occurance of '-', and the item to be the text from that position up to the next occurance of '-'.
    Of course once it then had a filename of the datacore type it missed the end of the item as the item name contained a '-':
    Please Login or Register  to view this content.
    I have now altered the code to look for the first occurance of '-' in the text, and have the 'location' as everything before that.
    Then look BACKWARDS through the text for the first occurance of '-' in that direction, and then have the 'item' as everything between those 2 points.
    Hopefully that will sort out any issues you were having.

    I have also added a progress panel to try and avoid that 'feeling of doom' when the macro is taking it's time to run

    Does every file get updated every day, or is it possible there might only be 1 or 2 new files each day?
    I ask because at the moment the macro blanks the summary page, then imports the data from the most recent version of each file, which is fine if the majority of files have changed, however it could get tedious if the majoriity of the files haven't changed, and yet we are throwing away perfectly valid data and then spending time reimporting it. In that case I could add a 'logging' feature to the workbook so that it would remember which files it had already imported, and then only import those that are newer than the ones it has already done, (if that makes sense!).
    Of course there is no point in me adding this functionality if most of the files will be updated most times before the macro is run, as it will then be updating from every file anyway :P

    Let me know how you get on with this new version
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    07-02-2009
    Location
    Cannock, England
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: "application.FileSearch" Excel 2007 update

    As always, you got it working as intended.

    I love the progress bar :D It really does help with the feeling of impending doom.

    Regarding your idea about only updating the necessary files, I don't think that it'd make that much difference, because I will be updating the majority of the files each time I update the sheet. But good idea

    As I begin to really use the code you've been providing me, I'm coming across little updates that would be beneficial. I'll put together a list of very small things that could be tweaked to make the code perfect for me, they won't be massive things as the majority of the legwork has already been done. It'll be a while before I do this though, as I'm working hard on the Spreadsheet that uses this code, and I won't know exactly how to tweak it until my part of the work is finished. After all that, I might be able to get away with not needing to have the code tweaked at all!

    Thanks,
    Dan.

    ps. Changing subject to "SOLVED".

+ 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