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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Filesearch Module converted

Status
Not open for further replies.

Rzrbkpk

Technical User
Mar 24, 2004
84
US
I've used the module below in VBA for Access successfully. Now, I need to do something similar in VB. I'm using Visual Studio 8 and have very little experience with it. The problem I'm running into is that it does not like the syntax for my "Set" declaration. Any thoughts would be appreciated.

Private Sub Command0_Click
Set fs = Application.FileSearch
With fs
.LookIn = "C:\Close Date Reporting\Reports"
.Filename = "Close Date Notification from*.xls"
If .Execute .execute
For I = 1 To .FoundFiles.Count
DoCmd.TransferSpreadsheet acImport, ,"Master Report Table", .foundfiles (I), True, "A18:G126"
Else
MsgBox "There were no files found."
End If
End With
End Sub
 
The code above will work a little differnt in VB.net fo rone I would recommend adding a reference to the excell interop and then using that library.

Plenty of examples on Google.

Christiaan Baes
Belgium

"My old site" - Me
 
Sorry to be so dim, but I'm not sure I understand that. I guess instead of beating around the bush, I should really state what I'm wanting to do. I want to be able to do a filesearch using Visual Studio.
 
So you want to see if a file exists.

Then the System.io namespace has all the goodies

like file.exists()

directory.exists

and so much more.

Christiaan Baes
Belgium

"My old site" - Me
 
I'm still lost. Do you have an example?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top