The Dir function for VBA learning notes

Source: Internet
Author: User

Dir () is used primarily to obtain (traverse) the file name under the directory

Subopen_all_files ()DimAA=Dir("C:\Users\Administrator\Desktop\ new Folder \*.txt")'all files ending with TXT are opened, but only the first compliant file is opened here, and the next file is opened in the Do loop in turnWorkbooks.Open"C:\Users\Administrator\Desktop\ new folder \"+a Do 'iterates through all the file names in the specified format under the directoryA =Dir'before Dir () has opened a number of files, there is no need to write, to open the format of the file in turnIfA <>""  ThenWorkbooks.Open"C:\Users\Administrator\Desktop\ new folder \"+ A'open each file in a format that matchesElseExit SubEnd IfLoopEnd Sub

The Dir function for VBA learning notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.