+ Reply to Thread
Results 1 to 3 of 3

Dir Syntax Error

  1. #1
    Forum Contributor
    Join Date
    03-27-2015
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    141

    Dir Syntax Error

    Dear Experts,

    I currently encounter a problem on how to use DIR to open the specific files from a folder :

    1. The file names in the folder is "ProjectCode-YearMonth-Flex.xlsm"
    2. ProjectCode is a 5 digit number, and there are many ProjectCode files in the folder
    3. Example for the file name is 03028-201909-Flex.xlsm
    4. My VBA is basically to open each ProjectCode file and perform some action

    The codes just finish to the end without opening any files however hard I tried to modify, which I believe is due to syntax error in the DIR line

    Please Login or Register  to view this content.
    Grateful if anyone could help.

    Many thanks.

  2. #2
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    995

    Re: Dir Syntax Error

    Try something like this:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    03-27-2015
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Dir Syntax Error

    I'm not sure what has happened, as I didn't make any changes but somehow the macro works now.

    Thank you for your help.

+ 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. Excel macro (compile error. syntax error.) error
    By salar_younis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2014, 06:11 AM
  2. [SOLVED] first timer using VB to cut and paste macro - getting compile error syntax error
    By jopedder in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-24-2013, 11:45 AM
  3. Receiving following error “Complie error : syntax error” Help
    By masond3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-02-2012, 10:19 AM
  4. [SOLVED] Compile Error: Expected Expression, Syntax Error
    By gjohn282 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-20-2012, 11:28 PM
  5. Syntax Error and Compile Error: Expected Line Number or Label...
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-31-2011, 09:59 AM
  6. runtime error: syntax error or access violation
    By oucsester in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-03-2006, 12:55 PM
  7. [SOLVED] variable not declared error & syntax error
    By G. Beard in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2005, 05:05 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