OFF97: Microsoft Office 97 Programs FileSearch Fails on a Microsoft Windows 2000-based Computer (259738)
The information in this article applies to:
- Microsoft Office 97 for Windows
- Microsoft Access 97
- Microsoft Excel 97 for Windows
- Microsoft PowerPoint 97 for Windows
- Microsoft Word 97 for Windows
- the operating system: Microsoft Windows 2000
This article was previously published under Q259738 SYMPTOMS
Visual Basic code that references the Application FileSearch object may cause the following error on a computer that is running Microsoft Windows 2000 if the code includes a wildcard character in the FileName property:
Run-time error '5':
Invalid procedure call or argument
RESOLUTION
Use the Dir property to search for the files as shown in the following example. This example requires that you have .mdb files in the My Documents folder.
- Copy the sample database Northwind.mdb to the My Documents folder on a computer that is running Windows 2000.
- In Access 97, create a new database.
- Create a module, and then type the following line in the Declarations
section if it is not already there:
Option Explicit
- Type the following procedure:
Function TestDir(strPathName)
Dim searchFile As String
Dim resultString As String
Dim fileCounter As Integer
Dim messageString As String
fileCounter = 0
searchFile = Dir(strPathName)
If searchFile <> "" Then
fileCounter = 1
resultString = searchFile & vbCrLf
End If
Do While searchFile <> ""
searchFile = Dir
If searchFile <> "" Then
fileCounter = fileCounter + 1
resultString = resultString & searchFile & vbCrLf
End If
Loop
If fileCounter = 0 Then
messageString = "No files found"
Else
messageString = "Found " & fileCounter & " file/s named:" _
& vbCrLf & resultString
End If
TestDir = messageString
End Function
- To test this function, type the following line in the Debug window, and then press ENTER:
?TestDir("C:\My Documents\No*.mdb")
Note that the results are returned to the Debug window.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. REFERENCESFor more information about the Dir function, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type dir in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
Modification Type: | Major | Last Reviewed: | 5/23/2003 |
---|
Keywords: | kbbug kbdta kbnofix KB259738 |
---|
|