application.FileSearch not wroking in MS Access 2007

asifakhtar

New Member
Joined
Oct 13, 2009
Messages
13
Office Version
  1. 365
I have installed MS office 2007 and now the below coding is not working its shows me an error (Run time error 2455 )" You entered an expression that has an invalid reference to the property FileSearch "<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p> please help me for the below codding that works in MS access 2007 module </o:p>
<o:p>' Numbers of text files store in a table </o:p>
<o:p></o:p>Sub AddFile()
Set fs = Application.FileSearch
With fs
.LookIn = "S:\super pass card\Transaction 2010\December"
.FileName = "*.txt"
.Execute
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
DoCmd.TransferText acImportDelim, , "transactions", .FoundFiles(i), True

Next i
End With
End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Thanks for your help; please can someone help me with the script as I am not a programmer (I am fleet assistant) , before I was simply running the module which I haven’t return and know our company installed MS Office 2007 and I don’t know how to change the coding for 2007, the below codding store numbers of text files in a data base table.

Sub AddFile()
Set fs = Application.FileSearch
With fs
.LookIn = "S:\super pass card\Transaction 2010\December"
.FileName = "*.txt"
.Execute
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
DoCmd.TransferText acImportDelim, , "transactions", .FoundFiles(i), True

Next i
End With
End Sub
 
Upvote 0
This code will list all of your text files in the debug window and also tell you how many files it has found.

Sub AddFileNew()
Dim strPath As String
Dim strFile As String
Dim i As Integer
strPath = "S:\super pass card\Transaction 2010\December\"
strFile = dir(strPath & "*.txt")
Do While strFile <> ""
i = i + 1
Debug.Print strFile
strFile = dir
Loop
MsgBox "How many files found " & i
End Sub
 
Upvote 0
Sub AddFileNew()
Dim strPath As String
Dim strFile As String
Dim i As Integer
strPath = "S:\super pass card\Transaction 2010\December\"
strFile = Dir(strPath & "*.txt")
Do While strFile <> ""
i = i + 1
DoCmd.TransferText acImportDelim, , "transactions", strFile, True
strFile = Dir
Loop
MsgBox "How many files found " & i
End Sub


I have tried this coding but its shows me an error on red highlighted line, please solve for me<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
 
Upvote 0
Thanks Trevor !!
its should be
DoCmd.TransferText acImportDelim, , "transactions", strPath & strFile, True
Its working once again thanks a lot :)
 
Upvote 0
Pleased to read you have a solution, and happy to help.:rolleyes:
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,725
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top