![]() |
Search SharePoint for Workbook
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 |
Search SharePoint for Workbook
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 '/===============================/ -- Hope this helps. If it does, please click the Yes button. Thanks in advance for your feedback. Gary Brown "carmjo005" wrote: 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 |
Search SharePoint for Workbook
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 "Gary Brown" wrote: 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 '/===============================/ -- Hope this helps. If it does, please click the Yes button. Thanks in advance for your feedback. Gary Brown "carmjo005" wrote: 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 |
All times are GMT +1. The time now is 11:11 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com