Search SharePoint for Workbook

C

carmjo005

Is there a way to search a SharePoint site to see if a Workbook exists? I
have CanCheckOut working, but the problem is that if the workbook is already
checked-out or if it doesn't exist I think I get the same response(can't
checked-out). If the Workbook is already checked-out then I will display a
message "The file is already checked out. Try again later". However, if the
file does not exits then I want to search for an earlier file.
Thanks for your time and expertice in advance
 
G

Gary Brown

Here's a User-Defined-Function that might help...

'/===============================/
' Function Purpose:
' Return TRUE or FALSE
' strFileName should be full path
' and filename
' i.e. "C:\Temp\MyFile.xls"
'/===============================/
'
Public Function FileExists(strFileName As String) _
As Boolean
On Error GoTo err_Function

FileExists = False
If Dir(strFileName) <> "" Then
FileExists = True
End If

exit_Function:
On Error Resume Next
Exit Function

err_Function:
Debug.Print "Error: " & Err.Number & " - (" & _
Err.Description & _
") - Function: FileExists - Module: " & _
"Mod_Functions_FileExists - " & Now()
GoTo exit_Function

End Function
'/===============================/
 
C

carmjo005

Thanks Gary. I've tried something similar but just can't get "Dir" to work
within SharePoint(even with your code). My path and filename are correct and
work fine with Open(read-only), CanCheckOut and CanCheckIn. Used a work
around to first try to Open the workbook which generates no error if it
exists - seems to work but sloppy
Appreciate your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top