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

how to check if file is present 1

Status
Not open for further replies.

din2005

Programmer
Mar 22, 2005
162
0
0
GB
Hi i have this code which when button is pressed it will go and open the file, how do i take into account if the file is not present and give the user a msg saying file is not present!

Private Sub cmdCopyOrder_Click()

Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run "Z:\StockSystem\CopyOrders\" & Me.txtOrderNumber.Value & ".msg"

End Sub
 
I think the easiest way is probably using the Dir command.

Dir(filepath) it will return the same filename if it is there.
 
Code:
Dim objFileSystem As Object
Set objFileSystem =  
      CreateObject("Scripting.FileSystemObject")
 If objFileSystem.FileExists(strFileName) Then
 'code
 end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top