search
HomeComputer TutorialsComputer KnowledgeHow to use VBA programming to specify a folder path and open files matching a specific suffix in order

How to use VBA programming to specify a folder path and open files matching a specific suffix in order

VBA programming how to write the specified folder path and open the files that meet the suffix requirements in sequence

Sub Test()

Dim myPath As String, MyName As String

myPath = "C:\Documents\" 'Get Path

MyName = Dir(myPath) 'find the first file

If Right(MyName, 4) = ".csv" Then Workbooks.Open Filename:=myPath & MyName

Do While MyName """

MyName = Dir 'find next

If Right(MyName, 4) = ".csv" Then Workbooks.Open Filename:=myPath & MyName

Loop

End Sub

Excuse me, experts, how to select the file path and file name in which control to put in VBA

Sub DateSave()

Application.DisplayAlerts = False

ActiveWorkbook.SaveAs Filename:= _

ThisWorkbook.Path & "\"" & Date & ".xls", _

FileFormat:=xlNormal, _

Password:="", WriteResPassword:="", _

ReadOnlyRecommended:=False, _

CreateBackup:=False

Application.DisplayAlerts = True

End Sub

Please change "ThisWorkbook.Path & "\"" & Date & ".xls", _" to ""d:\" & Date & ".xls", _", where ""d:\" " This is the path you want to save.

Hopefully my answer is of help to you.

The above is the detailed content of How to use VBA programming to specify a folder path and open files matching a specific suffix in order. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:Excel办公网. If there is any infringement, please contact admin@php.cn delete
How to Solve Windows Error Code "INVALID_DATA_ACCESS_TRAP" (0x00000004)How to Solve Windows Error Code "INVALID_DATA_ACCESS_TRAP" (0x00000004)Mar 11, 2025 am 11:26 AM

This article addresses the Windows "INVALID_DATA_ACCESS_TRAP" (0x00000004) error, a critical BSOD. It explores common causes like faulty drivers, hardware malfunctions (RAM, hard drive), software conflicts, overclocking, and malware. Trou

How do I edit the Registry? (Warning: Use with caution!)How do I edit the Registry? (Warning: Use with caution!)Mar 21, 2025 pm 07:46 PM

Article discusses editing Windows Registry, precautions, backup methods, and potential issues from incorrect edits. Main issue: risks of system instability and data loss from improper changes.

How do I manage services in Windows?How do I manage services in Windows?Mar 21, 2025 pm 07:52 PM

Article discusses managing Windows services for system health, including starting, stopping, restarting services, and best practices for stability.

Discover How to Fix Drive Health Warning in Windows SettingsDiscover How to Fix Drive Health Warning in Windows SettingsMar 19, 2025 am 11:10 AM

What does the drive health warning in Windows Settings mean and what should you do when you receive the disk warning? Read this php.cn tutorial to get step-by-step instructions to cope with this situation.

which application uses ene.syswhich application uses ene.sysMar 12, 2025 pm 01:25 PM

This article identifies ene.sys as a Realtek High Definition Audio driver component. It details its function in managing audio hardware, emphasizing its crucial role in audio functionality. The article also guides users on verifying its legitimacy

why won't driver asio.sys loadwhy won't driver asio.sys loadMar 10, 2025 pm 07:58 PM

This article addresses the failure of the Windows asio.sys audio driver. Common causes include corrupted system files, hardware/driver incompatibility, software conflicts, registry issues, and malware. Troubleshooting involves SFC scans, driver upda

How do I change the default app for a file type?How do I change the default app for a file type?Mar 21, 2025 pm 07:48 PM

Article discusses changing default apps for file types on Windows, including reverting and bulk changes. Main issue: no built-in bulk change option.

How do I use the Group Policy Editor (gpedit.msc)?How do I use the Group Policy Editor (gpedit.msc)?Mar 21, 2025 pm 07:48 PM

The article explains how to use the Group Policy Editor (gpedit.msc) in Windows for managing system settings, highlighting common configurations and troubleshooting methods. It notes that gpedit.msc is unavailable in Windows Home editions, suggesting

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool