Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching Multiple Excel files 1

Status
Not open for further replies.

OneMadCoder

IS-IT--Management
Mar 26, 2008
59
I need to search (100 or so) multiple excel files for a specific field, all contained within one directory. Is there a way to easily do so without opening each one then selecting each tab to search.

If I could append them all that would be fine too...

I pulled this from the web, but encountered errors:
I've replaced the variables with my own

Sub find()
Dim myfile
Dim mypath
mypath = "C:\Users\Chris\Desktop\xls\As Run xls files"
Do
myfile = Dir(mypath & "*.xls")
' Search and Find
DoCmd.TransferSpreadsheet acImport, 8, "RSPF", mypath & myfile
myfile = Dir
Loop Until myfile = ""
End Sub
 
What about this ?
Code:
mypath = "C:\Users\Chris\Desktop\xls\As Run xls files\"
myfile = Dir(mypath & "*.xls")
Do Until myfile = ""
  DoCmd.TransferSpreadsheet acImport, 8, "RSPF", mypath & myfile
  myfile = Dir
Loop

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
No, same as before
Debug message is: Identifier under cursor is not recognized (acImport)

mypath = "C:\Users\Chris\Desktop\xls\As Run xls files\"
myfile = Dir(mypath & "*.xls")
Do Until myfile = ""
DoCmd.TransferSpreadsheet acImport, 8, "RSPF", mypath & myfile
myfile = Dir
Loop
 
Seems you automate msacces, so replace this:
DoCmd.TransferSpreadsheet acImport, 8, "RSPF", mypath & myfile
with this:
[!]yourAccessApplicationObject.[/!]DoCmd.TransferSpreadsheet 0, 8, "RSPF", mypath & myfile

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top