Solved

Check if files exist

Posted on 2006-11-07
1
167 Views
Last Modified: 2010-04-30
I want to check the contents of a folder and find out if ANY files exist with the extension .BAK anyone know a simple way to do this?

Cheers,

Andy
0
Comment
Question by:xizor
1 Comment
 
LVL 14

Accepted Solution

by:
Shiju Sasidharan earned 250 total points
ID: 17888077
place a file list box on your form and try this code

Private Sub Form_Load()
    File1.System = True
    File1.ReadOnly = True
    File1.Hidden = True
    File1.Visible = False
End Sub
Private Sub Command1_Click()
    If FindFile("C:\Your_Folder", "bak") Then  '<----- Change to your folder path
        MsgBox "File found"
    Else
        MsgBox "File not found"
    End If
End Sub
Private Function FindFile(Path As String, Extension As String) As Boolean
    File1.Pattern = "*." & Extension
    File1.Path = Path
    File1.Refresh
    If File1.ListCount > 0 Then FindFile = True
End Function
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question