+ Reply to Thread
Results 1 to 3 of 3

Find / open and update a file in a specific folder

  1. #1
    Forum Contributor
    Join Date
    10-07-2015
    Location
    cyprus
    MS-Off Ver
    Microsoft 365
    Posts
    182

    Find / open and update a file in a specific folder

    From a workbook, based on the information inside, I want to find / open and update the relevant row (if exists otherwise to add a new row) in a specific folder.

    in this specific folder, I want to find all the files which includes in the title for ex "AUG". In the folder, I can have different files which includes "SEP". For ex, I can have "P AND L AUG - SEP 16.XLSM" AND " P AND L - SEP - OCT 16.XLSM". In each of those files I want to update the relevant row or to create a new one if it does not exist yet

    in below code
    sfilter= "SEP"
    SFILE = P AND L AUG - SEP 16.XLSM"
    But at the line Workbooks.Open Filename:=sfile I get a message that 'P AND L AUG - SEP -16.XLSM' can not be found although it exists in the folder since sfile is found.

    Please Login or Register  to view this content.
    1. can someone tell me why I got this message error since my code correctly identify the title of the existing file.
    2. as mentioned at the beginning I can have several file which includes in their title "sfile", how can I open the first file matching the condition, update it , then close it and do same to the other

    the rest of my code updating the files is as follows:

    Please Login or Register  to view this content.
    thanks in advance for the tips

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Find / open and update a file in a specific folder

    On first look - SPATH is not your current working directory. So when you try to open the file that really exists in SPATH it actually try to open it from the current working directory, where the file does not exists.
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Forum Contributor
    Join Date
    10-07-2015
    Location
    cyprus
    MS-Off Ver
    Microsoft 365
    Posts
    182

    Re: Find / open and update a file in a specific folder

    I managed to correct the error and now to open the first file

    below correct code (which can maybe be simpler....but anyway working)

    Please Login or Register  to view this content.

+ 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. How to open specific file in a folder using VBA
    By Amar321 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-28-2016, 05:30 AM
  2. [SOLVED] vba to find and open specific folder
    By hassan khansa in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 02-08-2016, 11:06 AM
  3. Replies: 3
    Last Post: 12-28-2015, 08:14 AM
  4. VBA open yesterdays saved file in a specific folder
    By forfiett in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2014, 08:17 AM
  5. [SOLVED] Open specific folder, select file to open and copy then paste
    By Kranky in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-22-2012, 12:14 AM
  6. Find File in Directory(s) and Open Folder highlighting file
    By cpadude in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-08-2010, 05:39 AM
  7. Open File from specific folder
    By ateam in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-26-2009, 05:28 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